Is there a replacement in Scala for Java\'s int Arrays.binarySearch(Object[] array, object)?
int Arrays.binarySearch(Object[] array, object)
The problem is that Scala\'s Arrays are not covariant, so I
Scala 2.11 added scala.collection.Searching to the standard library. It uses binary search for indexed sequences and linear search otherwise.
import scala.collection.Searching._ Array(1, 2, 3, 4, 5).search(3)