I can define member extensions like this, but is there a way to use it?
interface Section<T> {
fun matches(item: T): Boolean
}
class MyList<T>{
val items: List<T> = listOf()
val Section<T>.firstMatch: Int
get() = items.indexOfFirst { this.matches(it) }
}
fun myMethod() {
val myList = MyList<String>()
val section = object : Section<String> {
override fun matches(item: String): Boolean =
item == "something"
}
/* ??? */
val x = section.firstMatch
}