On a side note: if I want to do an index for loop ...
# announcements
y
On a side note: if I want to do an index for loop do I need to use .forEachIndexed or could I just use an overload?
a
https://kotlinlang.org/docs/reference/control-flow.html#for-loops
Copy code
for ((index, value) in array.withIndex()) {
    println("the element at $index is $value")
}
y
Huh that's neat. Looks like withIndex() returns an IndexedValue type (which just looks like a pair tbh)
a
Yeah it looks just like one. but with the constraint that one value is an
int
. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-indexed-value/index.html
y
You get the added functionality of .equals .copy or whatever else. I love my data classes.