Scala 3’s explicit null feature is great, but it’s not as easy to work with as it is in Kotlin. There’s an nn
method for non-null assertions, but something like Kotlin’s Elvis operator would be pretty great too.
The lack of ?:
or something similar is sorely felt when I have multiple values and I want to chain them like I can Options with orElse
. Adding something like the Elvis operator feels like a small enough change that it could be added to Scala 3.0. Of course, the operator can’t be named ?:
, but something like |?
or even elvis
with low precedence would be really helpful.
What are your thoughts on this?