Is there a Kotlin-ish way to loop through some int...
# getting-started
c
Is there a Kotlin-ish way to loop through some integers but be able to control the iterator? E.g. I want to do something like:
Copy code
for (i in (0..100)) {
  if (i == 10) i += 10
}
s
Not directly, as far as I know. You could try using a tailrec fun instead, and pass the relevant step into it
c
Thanks. This is what I've gone for:
Copy code
var address = 0
while (address < rom.size) {
    val (operation, nextInstructionOffset) = getOperation(address)
    address += nextInstructionOffset
}
s
That works. I think it's also more readable than your original approach, if it were to have worked