hi, how can I refactor this with `indices` ```val ...
# getting-started
o
hi, how can I refactor this with
indices
Copy code
val n = arr.size
    for (i in 0 until n - 1) {
        for (j in 0 until n - i - 1) {
m
I believe this works, but leave it to you if it's more readable.
Copy code
val arr = arrayOf(1,2,3)

arr.forEachIndexed {index, value ->
    println("v:$value")
    arr.take(arr.size - index).forEach {
        println("int:$it")        
    }
}
o
very nice thank you Mike
m
Just be aware that
take
will create an intermediate list, so if you have a LARGE list, that could create a performance issue.