Similar to the map() method, this method invokes the
supplied partial function only if the supplied Either is a
Right.
Similar to the map() method, this method invokes the
supplied partial function only if the supplied Either is a
Right. Unlike map(), however, flatMap() does
not automatically rewrap the result in a Right; instead, it
expects the supplied partial function to return an Either.
This method is roughly analogous to the Scala Option class's
flatMap() function.
the mapped Right type
Partial function taking a value of type R
(i.e., what's stored in the Right side) and maps
it to an Either[L, R2].
Map an Either value only if it's a Right.
Map an Either value only if it's a Right. If it's a
Left, just return the Left unmodified.
This method is roughly analogous to the Scala Option class's
map() function.
the mapped Right type
Partial function taking a value of type R
(i.e., what's stored in the Right side) and maps
it to a value of type R2.
Enriched
Eitherclass, providingmapandflatMapmethods that map over andEitherobject if its value isRight(and permit easier use ofEitherobjects inforcomprehensions).