Dejan Lozanovic
09/17/2024, 10:07 PMephemient
09/17/2024, 10:22 PMephemient
09/17/2024, 10:26 PMMichael Paus
09/18/2024, 8:08 AMbytes
and create a ShortArray shorts
by reading short values from the buffer.
With Kotlinx-IO it looks like this:
Buffer().apply {
write(bytes)
shorts = ShortArray(NUM_VALUES) { readShort() }
}
With Ktor it looks like this:
ByteReadChannel(bytes).apply {
runBlocking {
shorts = ShortArray(NUM_VALUES) { readShort() }
}
}
With Ktor you have to deal with the fact that the read methods are suspending functions whereas in Kotlinx-IO they are not.