Skip to content

Instantly share code, notes, and snippets.

@yuhki50
Last active January 4, 2024 17:47
Show Gist options
  • Save yuhki50/ca8363c0bee588cd79ad6637edfaedf3 to your computer and use it in GitHub Desktop.
Save yuhki50/ca8363c0bee588cd79ad6637edfaedf3 to your computer and use it in GitHub Desktop.
Kotlin intArray to byteArray
val ints = intArrayOf(0x01, 0xFF)
val bytes = ints.foldIndexed(ByteArray(ints.size)) { i, a, v -> a.apply { set(i, v.toByte()) } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment