Sleepzy to Programmer Humor@lemmy.ml · 9 months agoElvisimagemessage-square35linkfedilinkarrow-up1164arrow-down111
arrow-up1153arrow-down1imageElvisSleepzy to Programmer Humor@lemmy.ml · 9 months agomessage-square35linkfedilink
minus-squaredev_null@lemmy.mllinkfedilinkarrow-up3·edit-29 months agoIt’s a shorthand for writing this: variable = if (input != null) input else default This is equivalent: variable = input ?: default The answers confusing it with the ternary operator are wrong.
It’s a shorthand for writing this:
variable = if (input != null) input else default
This is equivalent:
variable = input ?: default
The answers confusing it with the ternary operator are wrong.