Right

data class Right<out R>(val b: R) : Either<Nothing, R>
  • Represents the right side of Either class which by convention is a "Success".

Constructors

Link copied to clipboard
constructor(b: R)

Properties

Link copied to clipboard
val b: R
Link copied to clipboard

Returns true if this is a Left, false otherwise.

Link copied to clipboard

Returns true if this is a Right, false otherwise.

Functions

Link copied to clipboard
fun <T, L, R> Either<L, R>.flatMap(fn: (R) -> Either<L, T>): Either<L, T>

Right-biased flatMap() FP convention which means that Right is assumed to be the default case to operate on. If it is Left, operations like map, flatMap, ... return the Left value unchanged.

Link copied to clipboard
fun fold(fnL: (Nothing) -> Any, fnR: (R) -> Any): Any

Applies fnL if this is a Left or fnR if this is a Right.

Link copied to clipboard
fun <L, R> Either<L, R>.getOrElse(value: R): R

Returns the value from this Right or the given argument if this is a Left. Right(12).getOrElse(17) RETURNS 12 and Left(12).getOrElse(17) RETURNS 17

Link copied to clipboard
fun <L> left(a: L): Either.Left<L>

Creates a Left type.

Link copied to clipboard
fun <T, L, R> Either<L, R>.map(fn: (R) -> T): Either<L, T>

Right-biased map() FP convention which means that Right is assumed to be the default case to operate on. If it is Left, operations like map, flatMap, ... return the Left value unchanged.

Link copied to clipboard
fun <R> right(b: R): Either.Right<R>

Creates a Left type.