rightIfNotNull

inline fun <A, B> B?.rightIfNotNull(default: () -> A): Either<A, B>

Deprecated

This API is considered redundant. If this method is crucial for you, please let us know on the Arrow Github. Thanks! https://github.com/arrow-kt/arrow/issues Prefer Kotlin nullable syntax

Replace with

this?.right() ?: default().left()

Returns Right if the value of type B is not null, otherwise the specified A value wrapped into an Left.

Example:

import arrow.core.rightIfNotNull

fun main() {
"value".rightIfNotNull { "left" } // Right(b="value")
null.rightIfNotNull { "left" } // Left(a="left")
}