Michael de Kaste
09/28/2020, 9:04 AMval hasMyPredicate = someObject.someField.hisField.finalField != null
val someOtherBoolean = extensiveFunction()
when{
hasMyPredicate && someOtherBoolean -> {...}
!hasMyPredicate && someOtherBoolean -> {...}
!hasMyPredicate && !someOtherBoolean -> {...}
hasMyPredicate && !someOtherBoolean -> { val value = someObject.someField.hisField.finalField //value is nullable here, but the precondition made sure that it isn't }
}
How can I reference a deep inner value to be non-null and then when accessed it is autotyped to be non-null
I absolutely hate using !! and especially error("...") if the chain of access calls are all on non-settable values (they are all val)Uzi Landsmann
09/28/2020, 9:24 AMif (someObject.someField.hisField.finalField == null) {
// do something that exits the function
}