News for hackers. Stuff that matters.
Re:Scala 3 is not production ready by lmm on Monday November 21, 2022 @12:03AM (#33688998)
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
Re:Scala 3 is not production ready by lmm on Monday November 21, 2022 @01:06AM (#33689391)
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

Re:Scala 3 is not production ready by lmm on Monday November 21, 2022 @05:19AM (#33690932)
That's a lot more cumbersome to work with, and only possible at all if you're controlling the construction/population of the map rather than getting it back from a library or framework.