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

沒有留言:

張貼留言

ESP32 遠端感應控制系統

ESP32 遠端感應控制系統 目前的架構設計(結合了 ESP32、RFID、MQTT、Node-RED 與 Telegram 遠端雙向控制 ),這個系統的核心價值在於 即時感應、雲端中繼、智慧自動化與即時通訊回報 。 整個架構透過無線網路(Wi-Fi),將現場的硬體感測端、雲端訊...