| ▲ | setr 2 hours ago | |
I don't see how initial values solves for much, or how an Optional constitutes a workaround; if anything, I see initial/null values being a hack to get around Optional, which is an explicit declaration of what possibilities exist. Initial values, like null, is an attempt to smuggle the "unset" case into the type without declaring it. And like null, the defensively written logic should prefix every single usage with a check for validity. Optional is just a natural subset of the generalization that multiple possible states exist; in this case, just the two, and sum types to properly handle bigger sets. Initial/null never admit more than 2 possible states, and also believe everything is always in one of those 2 states. | ||