how can I write for loop with condition? ``` var i = 0 while (i < Math.min(all.size, maxSize)) { ...
u
how can I write for loop with condition?
Copy code
var i = 0
while (i < Math.min(all.size, maxSize)) {
}
other than while, so I can keep the i var indite the loop scope
l
Do you want i to be mutable?
d
for (i in 0 until Math.min(all.size, maxSize)) { ... }
is probably similar to what you are looking for.
u
oh until, thnx!
k
Unless
i
isn't simply being incremented every iteration... You could write a custom iterator or create an extra scope with
run
.