iamthevoid
12/03/2021, 3:14 PM@OptIn(ExperimentalContracts::class)
private fun <T : Any> T?.isNotNull(): Boolean {
contract {
returns(true) implies (this@isNotNull != null)
}
return this != null
}
Dominaezzz
12/03/2021, 3:19 PMDominaezzz
12/03/2021, 3:20 PM!= null
?iamthevoid
12/03/2021, 3:24 PMpaymentRule ?: return
works
check(paymentRule != null)
works
After all of they payment rule is not null in scopeiamthevoid
12/03/2021, 3:24 PMiamthevoid
12/03/2021, 3:25 PMDominaezzz
12/03/2021, 3:26 PMDominaezzz
12/03/2021, 3:26 PMDominaezzz
12/03/2021, 3:26 PMiamthevoid
12/03/2021, 3:26 PMDominaezzz
12/03/2021, 3:27 PMKlitos Kyriacou
12/03/2021, 3:30 PMfun foo(n: Int?) {
if (n != null) {
val m: Int = n
}
}
fun bar(n: Int?) {
val b = n != null
if (b) {
val m: Int = n
}
}
Dominaezzz
12/03/2021, 3:33 PMb
is used.