is a suspend function? Is it possible to catch an exception without using an
IO
?
s
simon.vergauwen
04/22/2020, 6:03 PM
Yes, since
suspend
models a
Continuation
which results in
Throwable
or
A
.
Similar to how
IO
results in
Throwable
or
A
.
simon.vergauwen
04/22/2020, 6:03 PM
The default constructor for
IO
is equivalent to
fun <A> IO(f: suspend () -> A): IO<A>
.
simon.vergauwen
04/22/2020, 6:05 PM
And so you could capture the result safely in
IO
and flatten it. Or any other
suspend
implementation
a
antonicg
04/22/2020, 7:07 PM
okay,thanks for the answer! I was asking because since Try was deprecated maybe makes sense to do the same but without the limitation of a suspend... But maybe, doesn't makes sense because it is a side effect... 🤔