| ▲ | cubefox 2 hours ago | |
Admittedly I don't really understand your construction. But this solution, if it works, doesn't look practical enough that it could be routinely used in practice like Foo|Null could be. By the way, some languages even shorten "Foo|Null" to "Foo?" as syntax sugar. > but you get to keep `null` away from your code... I don't think this would be desirable once we have eliminated null pointer exceptions with untagged unions. | ||
| ▲ | qsera an hour ago | parent [-] | |
>Admittedly I don't really understand your construction. It is quite simple. Instead of accepting a concrete type `Foo`, the function is changed to accept types that can be converted to `Option<Foo>`. Since both `Foo` and `Option<Foo>` can be converted to `Option<Foo>`, the existing call sites that passes `Foo` would not require changing. | ||