Phani Mahesh
08/18/2020, 9:41 AMEither<E,V>
. I want to run some extra checks on V
and end up with a Left
if they fail. Is there a utility function?Phani Mahesh
08/18/2020, 9:43 AM10.right().someFunc({ it.isOdd()}, { -> "Not Odd".left() })
, what can someFunc
be?Phani Mahesh
08/18/2020, 9:45 AMkioba
08/18/2020, 9:58 AMflatMap
as well in case you don’t have access to the Either construction.
fun myFunction(e: Either<Exception, Int>) =
e.flatMap{
Either.cond(it.isOdd(), { it }, { error })
}