Simple question for the following set of codes:
def nearby_az(string)
idx1 = 0
while idx1 < string.length
if string[idx1] != "a"
idx1 += 1
next #<--------------
end
idx2 = idx1 + 1
while (idx2 < string.length) && (idx2 <= idx1 + 3)
if string[idx2] == "z"
return true
end
idx2 += 1
end
idx1 += 1
end
return false
end
What does the word "next" do in the line with the commented arrow? And is "next" a method? If not, what's the correct technical jargon for this? Cheers
next
is not a method, it's a keyword. It applies to the outer while
loop in your example, it stops current iteration and 'calls' next one.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments