pakoito
04/01/2020, 11:46 AMTry
? Try and Either have the same APIs save for the constructor, which is what Either.catch
was added forJörg Winter
04/01/2020, 1:21 PMTry { }
So using the suspend-constructor Either.catch
is actually the 'official' replacement I guess ?Jörg Winter
04/01/2020, 1:22 PMJörg Winter
04/01/2020, 1:27 PMpakoito
04/01/2020, 1:34 PMpakoito
04/01/2020, 1:34 PMpakoito
04/01/2020, 1:34 PMpakoito
04/01/2020, 1:35 PMfun catchE(f: () -> A): Either<Throwable, A> =
try { f().right() } catch (t: Throwable) { t.left() }
Jörg Winter
04/01/2020, 2:36 PMrunCatching
with Result from stdlib :)pakoito
04/01/2020, 3:41 PM