Is there an existing utility/extension function th...
# arrow
r
Is there an existing utility/extension function that converts
R?
to
Either<L, R>
? Something like
Copy code
fun <L, R> R?.toEither(f: () -> L): Either<L, R> {
    return Option
        .fromNullable(this)
        .toEither(f)
}
☝🏼 1
i
you mean
right()
this turns an A to an
Either<Nothing, A>
If you do want to have that
f
function you would use `rightIfNotNull`:
Copy code
B?.rightIfNotNull(default: () -> A): Either<A, B>
p
@Robert Menke that’s exactly what you need 😄
r
Ahh awesome thanks @Imran/Malic and @pakoito 🙂