4 ms·
The concept of "there is no value here" is very useful. For example when trying to get a value from a hash map, or having optional parameters. But nil/null/und
by wongarsu 4y ago
The concept of "there is no value here" is very useful. For example when trying to get a value from a hash map, or having optional parameters.
But nil/null/undefined doesn't seem like the best way to go about this when designing a language. Not every value is optional, but if anything can be nil then you will spend a lot of unit tests and mental overhead on managing that disconnect. Systems that allow you to explicitly specify what can have no value (like SQLs NotNull, or Rust's or c++'s Optional) seem to do much better in terms of preventing bugs.