My rails app just started receiving this error today. Here is the code context. It is throwing the error on the line that starts with new_host_id
while @host_ids.include?(new_host_id)
i++
new_host_id = duplicate_host_id + i.to_s
end
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Ruby does not have a
++operator.The idiom in Ruby is
i += 1, which is the abbreviated form ofi = i + 1.Initially I thought that the posted code was incorrect and had to be
++ito generate that error. However, as Jörg W Mittag explains in a comment, this is not the case:Here is a simplified example showing the issue (the posted code refers to the first case):
I used
+and not++above to simplify the example: Ruby treats++iandi++as the productions+(+i)and [roughly]i+(+)..