Larry Garfield
06/04/2024, 7:40 PMresult.value
directly?Wesley Hartford
06/04/2024, 8:10 PMRight
(or Left
), you can access the value of either side simply using the value
property.Larry Garfield
06/04/2024, 8:13 PMWesley Hartford
06/04/2024, 8:14 PMonLeft
, onRight
, getOrElse
, etc.Larry Garfield
06/04/2024, 8:15 PMAlejandro Serrano.Mena
06/05/2024, 7:44 AMresult
has type Either.Right
, it behaves as that type in every situationsimon.vergauwen
06/05/2024, 12:28 PMreturns
& implies
contracts not supported in Kotlin 2.0. Otherwise this would've safely worked as well.
val x: Either<String, Int> = 1.right()
if (x.isRight()) {
x.value
}