2019年5月21日 星期二

Kotlin學習筆記(14) 使用字串板模

Kotlin學習筆記(14) 使用字串板模

fun main() {
    var a = 1
    // 模板中的简单名称:
    val s1 = "a is $a"

    a = 2
    // 模板中的任意表达式:
    val s2 = "${s1.replace("is", "was")}, but now is $a"
   
   
    println(s1)
    println(s2)

}

輸出畫面
a is 1 a was 1, but now is 2


沒有留言:

張貼留言

2026 作業1 MQTT基本觀念

 2026 作業1MQTT基本觀念 作業  參考下面網址 https://alex9ufoexploer.blogspot.com/2025/02/1-mqtt-relay-dht22-mqtt-box-pc-mymqtt.html https://alex9ufoexploer...