3 ms·
Any language that allows null should also provide a non-nullable type. Kind of the opposites of C#'s ?-operator that turns non-nullable types into nullable. In
by Too 14y ago
Any language that allows null should also provide a non-nullable type. Kind of the opposites of C#'s ?-operator that turns non-nullable types into nullable. In an SQL table it's very natural to choose whether an item is allowed to be null or not, so why not in a programming language?
It still baffles me why C# and Java does not have this.
At least in C# you can use code contracts to constrain functions to not accept "possibly" null values. I haven't used this myself but the demos I've seen look impressive. Anyone got hand on experience of this or similar?