Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
No difference. Ruby does not have i++, and to shorten 'i = i +1' you can use 'i +=1'
You can see the documentation, for example here: https://www.tutorialspoint.com/ruby/ruby_operators.htm
in my opinion, the first creates a new object equal to i + 1 and returns a reference, the second makes an increment for the original object.
If I'm not mistaken, then i = i + 1 will create 2 objects in memory, and i += 1 will only add one to the variable already in memory
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question