From: Sarah Allen Date: 2009-08-25T16:06:26+09:00 Subject: operators vs. methods Today I was just re-reading introductory Ruby docs as I prepare to teach a few newbies tomorrow and I find myself feeling newbie-ish. On ruby-lang.org's Ruby from other languagage highlights http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/ it points out that a method call is really a message to another object: # This 1 + 2 # Is the same as this ... 1.+(2) # Which is the same as this: 1.send "+", 2 That's all well and good, except that + isn't an ordinary method. If I take another method like div: # This 4.div(2) # Is not the same as 4 div 2 In fact the latter is a syntax error. When I first learned Ruby I was led to believe that + is just a method with a funny name, but now that I think about it that cannot be. Not only is there a special way that spaces are handled, but operator precedence is pretty special too. Where might I find this behavior documented? Is there a special list of operators? How are they different from methods? Can I create my own? Puzzled, or maybe I just need more sleep, Sarah -- Posted via http://www.ruby-forum.com/.