anli
11/11/2018, 8:53 PMwhen
?nfrankel
11/11/2018, 9:14 PMkarelpeeters
11/11/2018, 9:15 PMkarelpeeters
11/11/2018, 9:16 PMinline fun Any?.exhaustive() = Unit
, use like this:
when (x) { ... }.exhaustive()
It forces the when
to be an expression.karelpeeters
11/11/2018, 9:17 PManli
11/11/2018, 9:38 PMval <T> T.exhaustive: T
get() = this
here: https://proandroiddev.com/til-when-is-when-exhaustive-31d69f630a8b
But I have hoped something official is possible (that is to treat a warning as compile time error).karelpeeters
11/11/2018, 9:39 PM.exhaustive()
to return anything.anli
11/11/2018, 9:53 PMkarelpeeters
11/11/2018, 9:54 PMoshai
11/11/2018, 10:06 PMwhen
that I still want to handle all caseskarelpeeters
11/11/2018, 10:17 PMval Any?.exhaustive
get() = Unit
no need to make it more confusing.