或许你对他很陌生 那么看这样一段代码
指向TODO()
运行起来会怎么样呢
运行上述代码是没事的。
但是下面的代码就报错了
package com.anguomob.learn
const val number=1001;
fun main() {
when(number){
1-> TODO();
1001-> TODO();
}
}
报错内容
Exception in thread "main" kotlin.NotImplementedError: An operation is not implemented.
at com.anguomob.learn.LearnKTKt.main(LearnKT.kt:6)
at com.anguomob.learn.LearnKTKt.main(LearnKT.kt)
其实TODO就是一个Nothing类型
当然不仅仅todo
也有像 exitProcess
他们都是要抛出异常来进行退出 所以就用到了这个