Why doesn't this work? I'm getting unexpected keyword_end.
while(!k && DATA[q])
if DATA[q] == 'aa' && DATA[p] == 'aa'
pl = DATA[r]
for i in 0..pl
PACK[i] = DATA[i+4]
end
k+=1 #end while
else
q++
p++
r++
end
end
答案 0 :(得分:4)
You are getting error because ++
does not work in Ruby.
Ruby has no pre/post increment/decrement operator. For instance, x++ or x-- will fail to parse. More importantly, ++x or --x will do nothing! In fact, they behave as multiple unary prefix operators: -x == ---x == -----x == ...... To increment a number, simply write x += 1.
source (which indeed are the words of Ruby's author himself.)
You should replace them as follows:
q+=1
p+=1
r+=1