jroid8@lemmy.world to Programmer Humor@lemmy.ml · 9 months agoknow the features of your languagelemmy.worldimagemessage-square144fedilinkarrow-up1640arrow-down124
arrow-up1616arrow-down1imageknow the features of your languagelemmy.worldjroid8@lemmy.world to Programmer Humor@lemmy.ml · 9 months agomessage-square144fedilink
minus-squareKnusper@feddit.delinkfedilinkarrow-up35arrow-down3·9 months agoI enjoy this: return a.or(b); But yeah, that requires an Option type rather than null pointers…
minus-squaremea_rah@lemmy.worldlinkfedilinkarrow-up6·9 months agoIs that Rust? Assuming a is an Option (which would be close approximation of OP’s nullable type) and assuming b is not null, then this would be closer to the original idea: a.unwrap_or(b) It returns value of a if it’s not None rather than Option.
I enjoy this:
But yeah, that requires an
Option
type rather thannull
pointers…a?.or(b)
Kotlin go brr
a ?: b
Is that Rust? Assuming
a
is an Option (which would be close approximation of OP’s nullable type) and assuming b is not null, then this would be closer to the original idea:a.unwrap_or(b)
It returns value of
a
if it’s not None rather than Option.