```fun <T:Comparable<T>>linearSearch(l...
# kotlin-native
m
Copy code
fun <T:Comparable<T>>linearSearch(list:List<T>, key:T):Int?{
    for ((index, value) in list.withIndex()) {
        if (value == key) return index
    }
    return null
}
I was learning linear search algorithm in kotlin but there is a thing why we used comparable interface here can you explain logic of comparable part?
n
This isn't Kotlin Native related. Use the #random channel instead.