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

  • 关于我们
  • 免责声明