【深入kotlin】 - 基础语法(二)_kotlin when需要判空吗-CSDN博客

网站介绍:文章浏览阅读1.8k次。Import同 Java 一样,位于同一包内的 class 不需要 import,否则需要 import。但可以指定别名:import com.example.xxx as zzz将 xxx 导入,并重命名为 zzz。判断if 比 swift 中有所扩展。比较特别的地方是支持三目运算(swift 中时 ? : 三目运算符):a = if(c==b) c else b甚至可以使用多行语句,最后一句的表达式自动返回(不需要 return):str = if(a<0) { printl_kotlin when需要判空吗