<@U0B8ZP13Q> Interesting, from experience with Sca...
# arrow
r
@cedric Interesting, from experience with Scala I would advise you don’t do that for Option. In Scala there is a difference between
Option(null)
(returns
None
) and
Some(null)
(returns an Option holding
null
). It’s understandable but can be confusing and lead to bugs as not everyone knows this edge case. So for safety you end up creating/assigning with
Option
and only using
Some
for pattern matching/test assertions. Not really tried that in Kotlin, as I tend to use Option.fromNullable which seems to work in a sane manner 🙂
Just checked and
Option.fromNullable
works as I would’ve expected (passing in a null nullable returns an empty option) In fact, I ended up writing a test for that exact scenario in my extension method (still on kategory here…)
c
@rawtoast It seems to me this practice is more due to a Scala limitation and/or convention(?)
a
maybe the fact that every instance in scala is nullable could play a role here?
r
Yes it’s very weird in Kotlin, especially with
nullable
. The languages definitely differ here