3 ms·
> null is typically used as a flag value, but the meaning can be ambiguous Languages like Haskell or Rust handle this in a straightforward way by removing the
by reificator 6y ago
> null is typically used as a flag value, but the meaning can be ambiguous
Languages like Haskell or Rust handle this in a straightforward way by removing the null and using sum types to replace them.
> maybe it's the absence of a value
Option<T> contains a possible value, or nothing. https://doc.rust-lang.org/std/option/ https://doc.rust-lang.org/std/option/
> maybe an error occured
Result<T, E> contains either a value or an error. https://doc.rust-lang.org/std/result/index.html https://doc.rust-lang.org/std/result/index.html
> Sometimes it has more than one meaning for the same type.
Result<Option<T>, E> is a result that might have a value.