```val a: Byte = 46 val b: Byte = 2 val real = (b ...
# announcements
k
Copy code
val a: Byte = 46
val b: Byte = 2
val real = (b shl 8) + a
👍 1
d
shl
doesn't have a version for Bytes
k
Cast away simple smile
The devs have said they're holding off on these things because the might be real operators for them and there might even be unsigned integer types in the future.
d
Yeah, I'm honestly surprised that you can add bytes directly. The reason being they don't like adding primitive operations for something that doesn't have a JVM bytecode mapping (ie. there's no bytecode for
byteOne + byteTwo
AFAIK, and Java actually does it by implicitly casting).
But I guess enough people were running into the issue they may have changed it?
k
Huh I didn't know that, thanks!
g
Implicit casting is the thing that Kotlin Team tries to avoid as much as possible.