Reputation: 697
x + y
is syntactic sugar for
x.send(:+, y)
What is this a syntactic sugar for?
x += y
I've tried
x.send(:+=, y)
but it doesn't work
Upvotes: 6
Views: 699
Reputation: 52377
It is not a method. It is a short way (syntactic sugar) for writing following:
x = 1
#=> 1
x += 1 # same as x = x + 1
#=> 2
Upvotes: 7