thanerian
11/19/2019, 12:22 PMImran/Malic
11/19/2019, 12:53 PMMeta
, which can give you an automatic exhaustive when expression on a Union Type. It’s not implemented, yet.thanerian
11/19/2019, 1:41 PMImran/Malic
11/19/2019, 1:59 PMwhen
should be pretty easy. So Something like this:
val a: Union3<Int, String, Long> = TODO()
when(a){
is Int -> doOnInt(a)
is String -> doOnString(a)
is Long -> doOnLong(a)
}
is possible. But don’t take that as is. This is just to showcase, how it may look like.thanerian
11/19/2019, 2:03 PMImran/Malic
11/19/2019, 2:03 PMwhen
is not even needed, because Unions
can do the conversion to Null, whenever the Type you care about is not the one you expectraulraja
11/19/2019, 2:11 PMImran/Malic
11/19/2019, 2:11 PM