8 ms·
For a type of "an object" or "a value", null is wrong. For a type of "maybe an object" or "maybe a value", null is not wrong. There is nothing fundamentally w
by Dylan16807 11y ago
For a type of "an object" or "a value", null is wrong.
For a type of "maybe an object" or "maybe a value", null is not wrong.
There is nothing fundamentally wrong with letting null exist in some form, especially if you hide it behind an Option<> interface.
The problem is when people use the wrong type.
> Surely it is true or false, but not null. Otherwise you surely have the wrong type?
Nullable boolean is not the same type as boolean. Problem solved.
The deep sense of wrongness is probably because so many languages force you to use nullable objects even when that's the wrong type. Not because nullables are inherently nonsensical.