3 ms·
> Any code calling a function that can return a Null should know that being handed a Null is a possibility and handle it, right? Well right now, the only way t
by HellzStormer 2y ago
> Any code calling a function that can return a Null should know that being handed a Null is a possibility and handle it, right?
Well right now, the only way to know is to read comments/docs. The problem is that for many older languages, the signature cannot make it clear that null is a possibility (unless you count "anywhere can be null regardless of the function", which isn't helpful).
The goal is to have a real distinction between can be null and wont be null so that things can be made explicit and the compiler can actually highlight places where the handling is missing.
It's a tool to help do exactly what you describe in a less error-prone way.