david-wg2
09/11/2018, 8:52 AMprivate fun whenTest(a: Boolean, b: Boolean) = when {
a && b -> ""
!a && b -> ""
a && !b -> ""
!a && !b -> ""
}
else
edwardwongtl
09/11/2018, 8:59 AMor
cases?david-wg2
09/11/2018, 9:02 AMPavlo Liapota
09/11/2018, 9:06 AMelse ->
instead of !a && !b ->
🙂david-wg2
09/11/2018, 9:07 AMedwardwongtl
09/11/2018, 9:10 AMelse
because there is no bound for when
, sth like when (someEnum) { ... }
. So the condition branches can be any statement that results in a Boolean
. Even though you’re branches covers all possibilities for a
and b
, there is still infinite possibilities out there that does not involve `a`/`b`.david-wg2
09/11/2018, 9:12 AMedwardwongtl
09/11/2018, 9:13 AMdavid-wg2
09/11/2018, 10:57 AM