arrow-core-data / arrow.core / Either / conditionally

conditionally

@JvmStatic inline fun <L, R> conditionally(test: Boolean, ifFalse: () -> L, ifTrue: () -> R): Either<L, R>

Will create an Either from the result of evaluating the first parameter using the functions provided on second and third parameters. Second parameter represents function for creating an Either.Left in case of a false result of evaluation and third parameter will be used to create a Either.Right in case of a true result.

Parameters

test - expression to evaluate and build an Either

ifFalse - function to create a Either.Left in case of false result of test

ifTrue - function to create a Either.Right in case of true result of test

Return Either.Right if evaluation succeed, Either.Left otherwise

Do you like Arrow?

Arrow Org
<