Left

data class Left<out L>(val a: L) : Either<L, Nothing>
  • Represents the left side of Either class which by convention is a "Failure".

Constructors

Link copied to clipboard
constructor(a: L)

Properties

Link copied to clipboard
val a: L
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: (L) -> Any, fnR: (Nothing) -> 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.