Re:Scala 3 is not production ready
by zaphirplane on Sunday November 20, 2022 @11:45PM
(#33688874)
What makes option useless
[ Parent
| on HN ]
Deliberate weird behaviour around nulls. In particular you can't have Some(null), which means you can't really use it to solve the problems it's meant to solve - one of the key motivating examples for why you want optionals is that if Map.get(x) returns null, you don't know if that means there's no mapping for x in the map, or there's an entry with key x and value null. So the idea would be to add Map.safeGet or some such which returns Option<V>, and then if it returns None there's really no mapping, and if it returns Some(null) then there's a mapping with value null. But you can't do that in Java because in the standardisation process they decided they... didn't want to allow it.
Re:Scala 3 is not production ready
by AzzieElbab on Monday November 21, 2022 @12:32AM
(#33689157)
I thought it was wrapping successful Java calls that return nulls. Try.toOption caught me off guard with this behaviour
Did you reply to the wrong comment? I'm talking about Java's Optional implementation.
Re:Scala 3 is not production ready
by zaphirplane on Monday November 21, 2022 @04:50AM
(#33690763)
Isn’t that a map of optionals
Optional::Empty, optional with value or null ?
Your 3 states