What is the method symbol for + = in ruby?

x + y 

- syntactic sugar for

 x.send(:+, y) 

What is this syntactic sugar?

 x += y 

I tried

 x.send(:+=, y) 

but it does not work

+5
source share
1 answer

This is not a method. This is a shortcut (syntactic sugar) for writing the following:

 x = 1 #=> 1 x += 1 # same as x = x + 1 #=> 2 
+5
source

All Articles