3 ms·
The proper way to do this is to have something like in Scala where you say Option(foo) if you want "foo" coerced to either Some(...) or None based on its
by lomnakkus 12y ago
The proper way to do this is to have something like in Scala where you say
Option(foo)
if you want "foo" coerced to either Some(...) or None based on its nullity. It doesn't prevent you from using
Some(null)
if that's what you really mean. (Though I think it might be a reasonable idea to actually throw an error in such a case. However, there should be a way to construct a Some(null), perhaps with a name that suggests that it's not recommended. Perhaps something with "unsafe" or "unguarded" in the name.)
- louthy 12y ago> Perhaps something with "unsafe" or "unguarded" in the name. That seems like a reasonable approach.