Quick actions

cmd+k|ctrl+k

Navigation

Languages

If Expression

Snippet info

Language

Kotlin

Visibility

public

Author

habib17

Created

2019-10-31T12:21:29Z

Updated

2019-10-31T12:21:29Z

fun main(args : Array<String>){
   ifElseOnVariabel()
}

fun ifElseGayaKu(){
   val openHours = 7
   val now = 20
   if(now > openHours){
       println("Office already open")
   }
   else{
       println("Office is closed")
   }
}

fun ifElseGayaDicoding(){
    val openHours = 7
    val now = 20
    val office : String
    if(now > openHours){
        office = "Office already open"
    }
    else{
        office = "Office is closed"
    }
    print(office)
}

fun ifElseOnVariabel(){
    val openHours = 7
    val now = 20
    val office : String
    office = if (now > openHours){
        "Office already open"
    }
    else{
        "Office is closed"
    }
    
    println(office)
}
INFO