CLOVIS
02/26/2024, 2:48 PMisRunning = result != null && result.isActive
isRunning = !(result == null || !result.isActive)
ephemient
02/26/2024, 3:06 PMisRunning = result?.isActive == true
Joffrey
02/26/2024, 4:03 PM== true
slightly less readable than the clear null check + regular boolean check. In general I don't find that saving a few characters is worth this slight readability drop.Joffrey
02/26/2024, 4:03 PMephemient
02/26/2024, 4:18 PM?.
version easier to read than the more complex boolean expression. there's three states: null
, false
, and true
, and you can clearly see which ones passJoffrey
02/26/2024, 4:21 PMephemient
02/26/2024, 4:23 PM== true
or == false
with `null`able Boolean
tooJoffrey
02/26/2024, 4:24 PMShaun Burch
02/28/2024, 3:58 AMisRunning = result?.isActive ?: false
I prefer to nip nullability asap, but if unable to prior β like stating the result when null with Joffrey
02/28/2024, 8:39 AM