r

    rrader

    3 years ago
    Why Kotlin does not have
    Either
    class? https://www.scala-lang.org/api/2.9.3/scala/Either.html
    m

    Mike

    3 years ago
    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

    3 years ago
    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

    3 years ago
    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.
    robin

    robin

    3 years ago
    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