YouKnowWhatScrewThis YouKnowWhatScrewThis - 6 months ago 20
Ruby Question

What is the difference between += and =+ in Ruby?

I am just learning Ruby and I want to know the difference between

a += b


a =+ b

Answer Source
  1. a += b is syntactic shorthand for a = a + b
  2. a =+ b is similar to a = + b

So, firstValue = firstValue + secondValue is the same as firstValue = firstValue.+(secondValue) in ruby. firstValue + = secondValue – increment Add the value of secondValue to the value of firstValue , store the result in firstValue, and return the new value.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download