3 ms·
It's been awhile since I've been in C#, but in other static languages like Rust and Kotlin with type inference, it would look more like: public Result<Somethin
by lllr_finger 7y ago
It's been awhile since I've been in C#, but in other static languages like Rust and Kotlin with type inference, it would look more like:
public Result<SomethingGood, SomethingBad> PerformUpdate(int goodThingId, UpdateForm form) { ... return Err(error); ... return Ok(obj); }
which is considerably less boilerplate-y. When there are three cases you want to consider, that's no longer a sum type consisting of just success or failure - that's a different sum type. Maybe even represented as Result<ThreeCases, Error>.