gildor
02/06/2018, 3:05 AMianbrandt
02/06/2018, 4:00 AMbyteArrayOf(0xB0.toByte(), 0x7B, 0x00)
works. The only reason you need the toByte()
on 0xB0
is because it's not a valid signed two's complement byte, and needs to be truncated.
In either case, byte literals are not needed here as the type is inferred from the parameter type: `byteArrayOf(vararg elements: Byte)`: byteArrayOf(11, 123, 0)
. As a consequence of this proposal, I would assume they could be used though, if desired: byteArrayOf(11b, 123b, 0b)
(or (11y, 123y, 0y)
).gildor
02/06/2018, 4:44 AMbenleggiero
02/06/2018, 5:34 AMbenleggiero
02/06/2018, 5:36 AM0xB0
require .toByte()
in Kotlin/Native? I’ve not read up too much bit I think there are `UInt8`s over there which would gladly hold a 0xB0
ianbrandt
02/06/2018, 6:11 AMtoByte()
calls, or something else?
Also, how does hex literal assignment to unsigned types apply to the addition of byte and short literals to Kotlin? Presumably, the compiler should accept any literal for assignment if it represents a valid value for a known type (after any implicit conversion, which Kotlin eschews: https://kotlinlang.org/docs/reference/basic-types.html#explicit-conversions), and reject it otherwise.gildor
02/06/2018, 6:16 AMfavor of or against byte literals, or just adding an FYI?In favor. but my example obviously wrong