conner
11/03/2021, 11:35 AMif let Left(err) = myEitherValue { /* do something with err */ }
? basically i want to run a block if myEitherValue
is Left
, and i would like to avoid casting itconner
11/03/2021, 11:37 AMfun <E, T> Either<E, T>.ifLeft(f: (E) -> Unit) = when(this) {
is Either.Left<E> -> f(this.value)
else -> Unit
}
but maybe this is built-in or there's a more idiomatic way? 🙂conner
11/03/2021, 11:37 AMtapLeft
is what i want 🙂 (just need to upgrade to 1.x)Peter
11/03/2021, 11:45 AMPeter
11/03/2021, 11:46 AM