3 ms·
That sounds like you should be using Result<T, E> to handle the two E cases you are describing. Success with Ok(T), with Err(Missing File) plus Err(Missing Sett
by evrimoztamur 2y ago
That sounds like you should be using Result<T, E> to handle the two E cases you are describing. Success with Ok(T), with Err(Missing File) plus Err(Missing Setting).
- dwaite 2y agoProbably. A case I see more often is a dictionary with nullable values. A T? return can't distinguish key missing or key present with null value. Which leads to a bit of an argument - nesting gives poor ergonomics, while collapsing impacts the ability to write generic code.
- tubthumper8 2y agoWhich you can't do in C# either without sum types :)