Ruckus
06/06/2018, 9:31 PMclass Ref<K: Comparable<K>, T>(val key: K, val value: T) : Comparable<Ref<K, T>> {
override fun compareTo(other: Ref<K, T>) = key.compareTo(other.key)
}
fun main(args: Array<String>) {
val list = mutableListOf<Ref<Int, *>>()
list.sorted() // ERROR: Ref<Int, *> is not a subtype of Comparable<Ref<Int, *>>
}
Any ideas?ilya.gorbunov
06/06/2018, 10:11 PMRef
as
class Ref<K: Comparable<K>, T>(val key: K, val value: T) : Comparable<Ref<K, *>> {
override fun compareTo(other: Ref<K, *>) = key.compareTo(other.key)
}
Ruckus
06/06/2018, 10:22 PM