5 ms·
Will we ever get to see golang-style multiple return values/results?
by splittingTimes 7y ago
Will we ever get to see golang-style multiple return values/results?
- rohan1024 7y agoMethod chaining becomes complicated if you have multiple return values. In Go, you can't return error values if you want to do method chaining. Error handling then becomes even more complicated.
- Polyisoprene 7y agoI would like to have the result type for this, like in Rust: enum Result<T, E> { Ok(T), Err(E), }
- lllr_finger 7y agoI've implemented this in Kotlin with sealed classes, and it's slowly taking over within our org. You don't get a few things (like the ? sugar) but it's still really nice. I have no idea why the Kotlin std lib has a Result type but limits it to exceptions - such a missed opportunity.
- kitd 7y agoI find using Optional a better alternative in typical "result|error" scenarios.