3 ms·
If when the type of a function F is "Foo or Null", you can express it as something like F(...): Foo? and if you're later forced to deal with such a value, Nul
by the_af 12y ago
If when the type of a function F is "Foo or Null", you can express it as something like
F(...): Foo?
and if you're later forced to deal with such a value, Null cannot catch you by surprise, then haven't you just rediscovered Option types?
If, on the other hand, "?" is just an operator you use on values that can be null, to guard against an exception, this seems less useful. Are you going to wrap every return value of every function call with it? What happens if you forget? How can you know, at a glance, if a function may return a null value?