Kotlin if Expression In Kotlin, if is an expression is which returns a value. It is used for control the flow of program structure. There is various type of if expression in Kotlin. if-else expression if-else if-else ladder expression nested if expression Traditional if Statement Syntax of traditional if statement if(condation){ //code statement } Syntax of traditional if else statement if(condation){ //code statement } else{ //code statement } Kotlin if-else Expression As if is an expression it is not used as standalone, it is used with if-else expression and the result of an if-else expression is assign into a variable. Syntax of if-else expression val returnValue = if (condation) { //code statement } else { // code statement } println(returnValue) Kotlin if-else Expression Example Let's s...
FOR BEGINNER PROGRAMMER & COMPUTER SCIENCE STUDENTS