Re:The Next Step for Generics
by sedatk on Tuesday June 16, 2020 @04:38PM
(#23543774)
You can also constrain a generic type only to value types in C#:
In that case it can't be null with C# either.
[ Parent
| on HN ]
Re:The Next Step for Generics
by AaronFriel on Tuesday June 16, 2020 @04:43PM
(#23543839)
Then you can't construct it unless it's successful, no?
A Result<T> that can only contain successful values doesn't seem very useful
You can, it's possible to address "missing values" with a default construct. Example:
int x = default; // x becomes zero
T x = default; // x becomes whatever the default value for struct is
Re:The Next Step for Generics
by AaronFriel on Tuesday June 16, 2020 @07:25PM
(#23545587)
Then we're back to accessing that value being an enormous footgun, yes?