In kotlin, I have a data class like this:
data class MyModel (
val key: String,
val myValue: String
)
I have an ArrayList of above model:
val myList: ArrayList<MyModel>
I don't know how to get the index of an element by passing the key:
fun getPosition(key: String): Int = myList.indexOf(/* what to do here? */)
----edit----
Assume that keys are unique.
ItemKeyProviderinRecyclerViewinandroid, for that I needed to know this.