3 ms·
I'm not sure you quite said this but nullable isn't just another word for Optional with syntactic sugar. You can have Optional<Optional<Integer>>, but Integer?
by dllthomas 5y ago
I'm not sure you quite said this but nullable isn't just another word for Optional with syntactic sugar. You can have Optional<Optional<Integer>>, but Integer?? is not a thing. This means you can't (or shouldn't?) use it for, say, return value of a generic "get a value from a map" because you might want to be able to store nullable values in the map and probably want to distinguish "it wasn't there" from "it was there but the value was null". IIRC, in some languages with generics and nullable you can't actually write a function that applies ? to a generic argument, because there's no way to say that the generic argument isn't itself nullable.