Is there some better form than .toByte() for case ...
# getting-started
k
Is there some better form than .toByte() for case below?
Copy code
val myVal: Byte
...
if(myVal != 0.toByte()) {}
t
you could do
byte.compareTo(0) != 0
, but i don't really think it's better
you avoid the
toByte()
though ¯\_(ツ)_/¯
a
You could make a
val Int.b get() = toByte()
or something similar to do
if(myVal != 0.b)
, not sure if that's a good approach