louiscad
04/25/2017, 9:25 AM0x
prefix to each hex byte, and when it reaches values that are equivalent negative 8 bit integers, you need to add .toByte()
, plus the comma and space between each byte.
This is extremely verbose, and I had to use hex string to byte array conversion instead to make my code readable.
Could Kotlin 1.2 allow us to write byte array literals more easily, please?
Here's how I can do it for now:
private val SERVICE_DATA_MASK = byteArrayOf(0xFF.toByte(), 0xFF.toByte(),
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
)
Here's how I'd like to do it:
private val SERVICE_DATA_MASK = [0xFF_FF_00_00_00_00_00_00_00_00_00_00_00_00]
I'd also enjoy being able to omit the first hex character of a byte if it's zero to shorten it further:
private val SERVICE_DATA_MASK = [0xFF_FF_0_0_0_0_0_0_0_0_0_0_0_0]
What do you think about this? Anyone has a better syntax proposal?