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 模擬RFID ,LED + Python TKinter SQLite

 WOKWI ESP32 模擬RFID ,LED + Python TKinter SQLite  WOKWI ESP32程式 #include <SPI.h> #include <MFRC522.h> #include <WiFi.h> #i...