Sergio C.
06/02/2021, 9:55 PMephemient
06/02/2021, 10:03 PMephemient
06/02/2021, 10:05 PMVampire
06/02/2021, 10:20 PM_
=` or val o_O =
. :-)
Another way that is not an assignment, does not need a library, does not pollute the Any
namespace and does not impact runtime performance as it is an inlined no-op is this variant:
when (...) {
...
}.let { /* it be exhaustive */ }
Javier
06/02/2021, 10:26 PMDo exhaustive when (...) { }
Vampire
06/02/2021, 10:28 PMJavier
06/02/2021, 10:30 PMephemient
06/02/2021, 10:35 PMephemient
06/02/2021, 10:39 PMval Do: Nothing?
inline get() = null
infix inline fun Any?.exhaustive(`when`: Any?) = Unit
to have no runtime impactSergio C.
06/02/2021, 10:40 PMSergio C.
06/02/2021, 10:41 PMephemient
06/02/2021, 10:41 PMephemient
06/02/2021, 10:41 PM.let {}
on the end, thoughVampire
06/02/2021, 10:42 PMVampire
06/02/2021, 10:43 PMobject Do {
inline infix fun exhaustive(`when`: Any?) = Unit
}
Vampire
06/02/2021, 10:43 PMJavier
06/02/2021, 10:43 PMSergio C.
06/02/2021, 10:44 PMJavier
06/02/2021, 10:44 PMephemient
06/02/2021, 10:44 PMobject
version, you still have the runtime impact of Do.getInstance()
Sergio C.
06/02/2021, 10:45 PM