Extension suggestion: Array<T>.contains


There doesn't seem to be a 'contains' method on Array. It would seem to be a sensible method to have as there is a similar method for List.

You can of course use

array.count { it == item } != 0

But it is kind of awkward. Therefore a contains method would be useful:

fun <T> Array<T>.contains(item: T): Boolean {   for (a in this) {   if (a == item) {            return true   }   }   return false }


array.any { it == item }


true enough, although contains still seems good since List and ArrayList has it :-)


Feel free to file a request into the issue tracker