知識點
35.Kotlin語言的可空性特點
36.Kotlin語言的安全調(diào)用操作符
37.在Kotlin中使用帶let的安全調(diào)用
38.Kotlin語言中的非空斷言操作符特點
39.Kotlin語法中對比使用if判斷null值情況
40.在Kotlin空合并操作符-金獅
41.在Kotlin語法中異常處理與自定義異常特點
42.Kotlin語言的先決條件函數(shù)
43.Kotlin語言的substring
44.Kotlin語言的split操作
45.Kotlin語言的replace完成加密解碼操作
46.Kotlin語言的==與===比較操作
47.Kotlin語言的字符串遍歷操作
48.Kotlin語言中數(shù)字類型的安全轉(zhuǎn)換函數(shù)
49.Kotlin語言中Double轉(zhuǎn)Int與類型格式化
50.Kotlin語言的apply內(nèi)置函數(shù)
51.Kotlin語言的let內(nèi)置函數(shù)
52.Kotlin語言的run內(nèi)置函數(shù)
53.Kotlin語言的with內(nèi)置函數(shù)
54.Kotlin語言的also內(nèi)置函數(shù)
55.Kotlin語言的takeIf內(nèi)置函數(shù)
56.Kotlin語言的takeUnless內(nèi)置函數(shù)
自定義異常
fun testException(){
try {
var info:String? = null
checkException(info)
println(info?.length)
} catch (e: Exception) {
println(e.message)
}
}
fun checkException(info: String?) {
info?:throw CustomException()
}
class CustomException:IllegalArgumentException("你的代碼不嚴謹")
try Catch
fun testException(){
try {
var info:String? = null
checkException(info)
println(info?.length)
} catch (e: Exception) {
println(e.message)
}
}
fun checkException(info: String?) {
info?:throw CustomException()
}
class CustomException:IllegalArgumentException("你的代碼不嚴謹")
splite 和 解構(gòu)
var jsonText = "user,password,lesson"
val list = jsonText.split(",")
val (v1,v2,v3) = list
println("解構(gòu):$v1,$v2,$v3")