https://kotlinlang.org logo
k

kirillrakhman

04/25/2017, 1:21 PM
since
Byte
has only a limited number of values, you could generate a source file that defines constants for each value. To get rid of
byteArrayOf
define a shorter helper function yourself.
Copy code
fun b(vararg bytes: Byte) = bytes

const val xFF: Byte = 0xFF.toByte()
const val xFE: Byte = 0xFE.toByte()
//..
const val x00: Byte = 0x00

fun foo() {
    val bytes = b(x00, xFF)
}
👍 1