bbaldino
12/09/2021, 8:52 PMResult
types. I have a method like this:
fun one(): Result<SomeType> {
return two()
.map { someOtherType ->
three(someOtherType)
.map { someType ->
doSomethingWithSomeType(someType)
someType
}
fun two(): Result<SomeOtherType> { ... }
fun three(someOtherType: SomeOtherType): Result<SomeOtherOtherType> { ... }
the compiler complains that I’m returning Result<Result<SomeType>>
instead of Result<SomeType>
, which I think I get…I just can’t remember the right way combination of `map`/`fold`/something else to “flatten” the result?Richard Gomez
12/09/2021, 9:08 PMflatMap
. Think of flatmap as "and then", whereas map is "transform value".bbaldino
12/09/2021, 9:09 PMflatMap
defined on Result
?Richard Gomez
12/09/2021, 9:10 PMRichard Gomez
12/09/2021, 9:11 PMbbaldino
12/09/2021, 9:11 PMResult
as a return had been stabilized, but since then I think every discussion I’ve read about it has had at least one person pointing to that lib 🙂bbaldino
12/09/2021, 9:12 PM