Assume that we have a class
class Foo
def + (element); end
def add (element); end
end
Now we can invoke these two methods like:
foo = Foo.new
foo.+('bar')
foo.add('bar')
And that's resonable. This is the right way of invoking methods.
My question is: Why we can do something like:
foo + 'bar'
but not:
foo add 'bar'
Does Ruby distinguish if method name is actually operator overloading? How does it work?