I can check if R::class == List::class but I can not check if R::class == List<Int>::class
val byteArray = byteArrayOf(1, 2, 3, 4, 8, 7, 0, 1, 2, 3.......)
// Define a generic function that returns a R from the byteArray
inline fun getValue(): R {
// Create a ByteBuffer from the byteArray
val buffer = ByteBuffer.wrap(byteArray)
// Return the value of the buffer as the specified type R
return when (R::class) {
Int::class ->
buffer.int as R
Float::class -> buffer.float as R
Double::class -> buffer.double as R
List::class -> { // I...