https://kotlinlang.org logo
#stdlib
Title
# stdlib
r

rrader

12/08/2018, 2:55 PM
Why Kotlin does not have
Either
class? https://www.scala-lang.org/api/2.9.3/scala/Either.html
m

Mike

12/08/2018, 3:00 PM
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

rrader

12/08/2018, 3:13 PM
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

aarjav

12/09/2018, 5:22 PM
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

robin

12/10/2018, 1:25 PM
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
3 Views