robin
11/23/2018, 11:42 AMdsavvinov
11/23/2018, 12:10 PMasync
returns something like Deferred<T>
, and Deferred<T>.await
returns T
.
Then, throw Exception()
actually has type in Kotlin — it’s Nothing
. So, type of job2
is Deferred<Nothing>
and job2.await()
returns Nothing
.
Now, the compiler is smart and knows that you can’t get a value of type Nothing
, so if something appears to return Nothing
, it actually means that the execution flow is interrupted (e.g. by exception)robin
11/23/2018, 12:30 PMrobin
11/23/2018, 12:31 PMdsavvinov
11/23/2018, 12:32 PMPaul Woitaschek
11/23/2018, 1:08 PMPaul Woitaschek
11/23/2018, 1:09 PMPaul Woitaschek
11/23/2018, 1:09 PMPaul Woitaschek
11/23/2018, 1:10 PMdsavvinov
11/23/2018, 1:23 PM