Why Kotlin does not have `Either` class? <https://...
# stdlib
r
Why Kotlin does not have
Either
class? https://www.scala-lang.org/api/2.9.3/scala/Either.html
m
It's not trying to be fully functional. Doesn't have option, try and others either. If you want that, the 'standard' is arrow-kt. #arrow
r
Well, it has Option as nullable types
We need Either to implement supporting for
undefined
like in JavaScript
Something like
Either<Int, Nothing>
or
Either<String?, Nothing>
a
I believe Kotlin way might be to use sealed classes. One benefit is you can even add 3rd case hopefully without too much code change.
r
Just for completeness' sake, nullable types in Kotlin are not really equivalent to a dedicated
Option
class, most notably because they can't be nested without losing information
💯 1