Throws an IllegalStateException if the value is false.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
var someState: String? = null
fun getStateValue(): String {
val state = checkNotNull(someState) { "State must be set beforehand" }
check(state.isNotEmpty()) { "State must be non-empty" }
return state
}
someState = ""
someState = "non-empty-state"
println(getStateValue())
}
Target: JVMRunning on v.2.1.20
Throws an IllegalStateException with the result of calling lazyMessage if the value is false.
Since Kotlin
1.0Samples
import kotlin.test.*
fun main() {
var someState: String? = null
fun getStateValue(): String {
val state = checkNotNull(someState) { "State must be set beforehand" }
check(state.isNotEmpty()) { "State must be non-empty" }
return state
}
someState = ""
someState = "non-empty-state"
println(getStateValue())
}
Target: JVMRunning on v.2.1.20