Ikem Nwodo
10/07/2018, 10:04 PMDico
10/07/2018, 10:09 PM.withIndex()
is an extension function that associates all elements to their index using a Pair
.
So you get an Iterable<Pair<Int, T>
.Pair
is a data class. Which provides component1()
and component2()
functions for its properties in the order they appear in the constructor.(index, element)
is deconstruction syntax, that uses those component functions in the same order.