3 ms·
The advantage of the Option type is that you don't need to check for nullability, you simply pattern match on Some(_) or None. A type of `some{T} | undefined` m
by angio 6y ago
The advantage of the Option type is that you don't need to check for nullability, you simply pattern match on Some(_) or None. A type of `some{T} | undefined` means that the expression can have values `Some(_)` or `None` or `undefined`, which defeats the point of the Option type!
- masklinn 6y agoExcept Erlang doesn't have a none. Nor an undefined for that matter. So `some {T} | undefined` means exactly that, there is no underlying null pointer which could sneak up on you. `undefined` here is not built-in type or value of the language, it's a standard atom like any other. So are null, nil, value or false (although false does have a special status in that it's the customary output of boolean operations alongside true).
- mbo 6y ago> A type of `some{T} | undefined` means that the expression can have values `Some(_)` or `None` or `undefined` Can you please explain this further? Why is `None` an inhabitant of this union?