-
Notifications
You must be signed in to change notification settings - Fork 12
Either
Alex Zuzin edited this page Apr 13, 2017
·
3 revisions
An ad-hoc Either
can be created the usual way:
val left: Either<Int, String> = left("wrong")
val right: Either<Int, String> = right(1)
An Either
can be converted into a Validation
:
val valid: Validation<Int, String> = right(1).validation()
val invalid: Validation<Int, String> = left("your value still sucks").validation()
A Kotlin Iterable
of Either
s can be sequenced as follows:
val eitherOfSeq: Either<List<Int>, Seq<String>> =
listOf(left("still does"), right(1)).sequence()
JΛVΛSLΛNG, (C) 2014 - 2017 javaslang.io