So, I am trying to define the operators + and += for a Ruby class and I try:
class A
def +(x)
end
def +=(x)
end
end
Ruby likes the + but not the +=, giving me this error:
syntax error, unexpected ‘=’, expecting ‘;’ or ‘\n’
What did I do wrong?
You cannot overload the assignment operators in ruby
Overloading Operators – Ruby