Ruby operator method calls vs. normal method calls

后端 未结 5 608
既然无缘
既然无缘 2020-12-15 23:52

I\'m wondering why calls to operator methods don\'t require a dot? Or rather, why can\'t normal methods be called without a dot?

Example

class Foo
  def +(obje         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 00:27

    Missing braces was some "advantage" for ruby 1.8, but with ruby 1.9 you can't even write method_0 method_1 some param it will be rejected, so the language goes rather to the strict version instead of freeforms.

提交回复
热议问题