<@U0ZFBBUBU> <@U0BFDUP0E> another option to avoid ...
# announcements
e
@groostav @jw another option to avoid allocating would be:
Copy code
inline fun <T, R> List<T>.binarySearch(
        element: T, 
        comparator: Comparator<in T>, 
        result: (isContained: Boolean, indexOrWouldBeIndex: Int) -> R
): R {
    val searchResult = Collections.binarySearch(this, element, comparator)
    val isContained = searchResult >= 0
    val indexOrWouldBeIndex = if (isContained) searchResult else -(searchResult + 1)
    return result(isContained, indexOrWouldBeIndex)
}