bjonnh
04/29/2020, 3:43 PMChilli
04/29/2020, 3:48 PMBrian Saltz Jr
04/29/2020, 3:56 PM.toByte()
on the literal in your when
and it should work.Brian Saltz Jr
04/29/2020, 3:56 PMwhen(b) {
0.toByte() -> true
else -> false
}
bjonnh
04/29/2020, 4:07 PMbjonnh
04/29/2020, 4:08 PMBrian Saltz Jr
04/29/2020, 4:18 PM<literal>.toByte()
in the when clause is handled at compile time, so it’s technically fewer operations, even though it’s a bit uglier. But .toInt()
is an extremely fast operation, so it’s not a big deal. Like I said, pedantic 🙂 I’d say go with whichever one looks better.bjonnh
04/29/2020, 4:53 PMBrian Saltz Jr
04/29/2020, 4:57 PMconst val NULL_BYTE: Byte = 0
Depending on why you’re using a when
on a byte to begin with, this may improve readability. Other than that, there’s no way to