3 ms·
Many functional programming languages have stronger type systems than C#. They typically don't accept null as a valid substitute for any type. To represent a nu
by actsasbuffoon 10y ago
Many functional programming languages have stronger type systems than C#. They typically don't accept null as a valid substitute for any type. To represent a nullable type, you wrap the value in a generic container. Think of it as being like an array that contains at most 1 item.
The interface of this generic container only allows you to interact with the (potentially) wrapped value in a way that is type safe. That doesn't completely eliminate having to think about how the business logic should differ for missing values, but it ensures that you'll never get a null pointer exception.