2 ms·
The difference is crucial. With these Sum types a variable of type Option<Dog> / Dog | null / Dog? might be a dog, but a variable of type Dog is definitely a do
by tialaramex 4y ago
The difference is crucial. With these Sum types a variable of type Option<Dog> / Dog | null / Dog? might be a dog, but a variable of type Dog is definitely a dog and the language has both of those types.
Languages which just have one nullable type here like Go must use their "might be a dog" type to represent things which definitely are a dog, meaning either you write paranoid checks everywhere or you might screw up - and it's no wonder there are more bugs as a result.