Lukasz Kalnik
left()
R?
R
class Either<L, R> private constructor( private val left: L, private val right: R, ) { companion object { fun <L, R> left(left: L): Either<L, R?> { return Either(left, null) } } }
Joffrey
Either.left<Int, String>(42)
Either<Int, String?>
Either<Int, String>
?
R : Any?
Marc
sealed interface Either<out L, out R> { data class Left<L>(val value: L) : Either<L, Nothing> data class Right<R>(val value: R) : Either<Nothing, R> companion object { fun <L, R> left(left: L): Either<L, R> { return Left(left) } fun <L, R> right(right: R): Either<L, R> { return Right(right) } } }
Either<L, R?>
A modern programming language that makes developers happier.