I iterate inside an array by using for-each range for Go. It works fine. But the problem is at some conditions I want to modify the index such like adding by 2 or more. How I can fix that problem? You can find out the sample code below.
for index,_ := range c {
if index < len(c)-2 && c[index + 2] == 0 {
index = index + 1
numberOfJumps++
} else if index < len(c) - 1 && c[index + 1] == 0 {
numberOfJumps++
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…