3 ms·
Non-nullable types allow functions to put the burden of checking for the existence of a value on callers. That means the check only has to happen in one place i
by fauigerzigerk 5y ago
Non-nullable types allow functions to put the burden of checking for the existence of a value on callers. That means the check only has to happen in one place instead of everywhere a string is used.
But I sort of agree that excluding nulls is only part of the solution, because existing isn't the only requirement that values have to meet. I often need strings to be non-empty or have a minimum length.
Many modern type systems allow you to define new types that conform to an existing type's interface. But it's often a rather convoluted affair.