I'm writing a B-tree, which may have many keys in one node, and I have encountered a problem. When I create an array of Ints everything works fine:
class Node<K: Comparable<K>> (val t: Int) {
val keys: Array<Int?> = Array<Int?> (t*2-1, {null})
}
But I want to create an array of Generics Ks:
class Node<K: Comparable<K>> (val t: Int) {
val keys : Array<K?> = Array<K?> (t*2-1, {null})
}
In this case compiler throws this error message:
'Kotlin: Cannot use 'K' as reified type parameter. Use a class instead.'
The question is How to create an array of Generics?
UPD: Thx for all the replies! It seems that MutableList is nice solution for my objective.