7
Effective Kotlin beta release - Marcin Moskala - Medium (medium.com)
IngramChen 積分 3 編輯於

我看了第一節,就看到它提到的兩個 edge case,下面兩個 compile 不會過:

//// case 1
val name: String? = "Marton"
val surname: String = "Braun"
val fullName: String?
  get() = name?.let { "$it $surname" } 

fun main() { 
  if (fullName != null) { 
     println(fullName.length) 
  } 
}

//// case 2
var list = mutableListOf<Int>()

fun main() {
   list += 1
}

還不錯的書,繼續讀…