Sourabh Rawat
12/16/2021, 7:09 PMeither
block from which I want to return a Left
value without any bind
calls. For example
either<Error, Response> {
when(foo) {
1 -> callFunReturningEither().bind()
else -> Error("foo is in else") <-- How to return this Left value?
}
}
I have tried Error("foo is in else").left().bind()
but it gives Returning type parameter has been inferred to Nothing implicitly. Please specify type arguments explicitly to hide this warning. Nothing can produce an exception at runtime.
which I think is expected.raulraja
12/16/2021, 7:35 PMbind
there is no point of wrapping in an either block. It would be in this case just:
val result: Either<Error, Response> =
when(foo) {
1 -> callFunReturningEither()
else -> Either.Left(Error("foo is in else"))
}
simon.vergauwen
12/16/2021, 8:20 PMwhen(foo) {
1 -> callFunReturningEither()
else -> Error("foo is in else").left()
}
either<Error, Response> {
when(foo) {
1 -> callFunReturningEither()
else -> Error("foo is in else").left().bind()
}
}
pakoito
12/16/2021, 8:53 PMbind
the return of 1 ->
I believeSourabh Rawat
12/17/2021, 4:31 AMbind
call in 1 ->
clause