2 ms·
No, you just are forced to use methods like foo.UnwrapOr(default_value) to get the Result. Or depending on the language, you get a compile error if you don't ha
by joshuamorton 6y ago
No, you just are forced to use methods like foo.UnwrapOr(default_value) to get the Result. Or depending on the language, you get a compile error if you don't handle both possible values of the Result enum in a switch statement or if/else clause.
See for example https://doc.rust-lang.org/std/result/enum.Result.html#method.unwrap_or_default https://doc.rust-lang.org/std/result/enum.Result.html#method... in rust, https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#orElse-T- https://docs.oracle.com/javase/8/docs/api/java/util/Optional... in Java, and https://en.cppreference.com/w/cpp/utility/optional/value_or https://en.cppreference.com/w/cpp/utility/optional/value_or in C++.
- AaronFriel 6y agoWho are you replying to? Is any of your elaboration related to this result type? class Result<T> { bool IsSuccess {get; set;} string Message {get; set;} T Data {get; set;} }
- joshuamorton 6y agoAh you're quite correct.