logo
  • 教程列表
  • SO官方文檔
  • 條件陳述
    • when 語句引數匹配
    • 當語句為表示式時
    • 標準 if 語句
    • if 語句作為表示式
    • when 語句而不是 if-else-if 鏈
    • 帶列舉的語句
  1. StackOverflow 文件
  2. Kotlin 教程
  3. 條件陳述
  4. 標準 if 語句

標準 if 語句

Created: November-22, 2018

val str = "Hello!"
if (str.length == 0) {
    print("The string is empty!")
} else if (str.length > 5) {
    print("The string is short!")
} else {
    print("The string is long!")
}

else-branches 在普通的 if 語句中是可選的。

  • if 語句作為表示式
  • 當語句為表示式時

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明