Related to topic above - would it be useful to ha...
# stdlib
e
Related to topic above - would it be useful to have
Boolean?.orFalse()
?
e
I saw code today like
Copy code
selectedDate?.isBefore(latestDate) == true
felt it would be easier to read
Copy code
selectedDate?.isBefore(latestDate).orFalse()
trying to avoid cognitive load about nullability
Thanks! Read the whole thread
c
Copy code
(selectedDate ?: Instant.DISTANT_FUTURE).isBefore(latestDate)
not sure that's better
l
Honestly the first one is pretty OK in my opinion. I had to decypher both other options
k
The
== true
idiom is commonplace and easily recognized as a check of a nullable Boolean. I don't think there's any need to invent workarounds.