Maybe you are very unfamiliar with him, so look at such a piece of code
Oriented TODO ()
How will it work?
Running the above code is fine.
But the following code gives an error
package com.anguomob.learn
const val number=1001;
fun main() {
when(number){
1-> TODO();
1001-> TODO();
}
}
Error content
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)
In fact, TODO is a type of Nothing
Of course not only todo
There are also things like exitProcess
They all have to throw an exception to exit, so this is used