I am writing a Kotlin program and I want to skip an iteration of the loop. I know the continue keyword, that jumps to the next interation, but is there a way to elegantly jump to the second next iteration, skipping the next iteration? I would imagine the code to look like this:
for(i in 0 until 10){
if(i == 5){
skip
}
println(i)
}
with the result being this:
0
1
2
3
4
7
8
9
PS: I know how I could do it other ways, but I am asking if there is a very easy or kotlin-native way of doing this.
skipmore elegant thancontinueaside from using a different word?continuegoes to the next iteration.skipwould skip the next iteration and continue at the iteration after the next