I'm new to Kotlin and for practice i'm converting my Java codes into Kotlin.
While doing that I'm facing one issue i.e., i'm unable to change the counter value inside the for loop. It actually says the variable is val.
for (i in 0..tokens.size){
// some code
if (memory[pointer]!=0)
i=stack.peek() // error here showing : val cannot be reassigned
}
I really want the counter variable to be changed inside the loop. Is there any other way that i can achieve this without any error in Kotlin?