2019年5月21日 星期二

Kotlin學習筆記(15) 條件表達式

Kotlin學習筆記(15) 條件表達式

fun maxOf(a: Int, b: Int): Int {
    if (a > b) {
        return a
    } else {
        return b
    }
}

fun minOf(a: Int, b: Int) = if (a < b) a else b

fun main() {
    println("max of 0 and 42 is ${maxOf(0, 42)}")
    println("min of 10 and 42 is ${minOf(10, 42)}")
}

輸出畫面
max of 0 and 42 is 42 min of 10 and 42 is 10

沒有留言:

張貼留言

WOKWI ESP32 LED Control , Node-Red MQTT SQLITE  

WOKWI ESP32 LED Control ,  Node-Red  MQTT SQLITE   const char broker[] = "test.mosquitto.org" ; //const char broker[] = "br...