Why does a method call need to be disambiguated when it can in principle be a constant?

后端 未结 3 638
野性不改
野性不改 2021-01-03 00:20

Method calls can usually omit the receiver and the parentheses for the arguments:

def foo; \"foo\" end
foo # => \"foo\"

In the case abov

3条回答
  •  忘掉有多难
    2021-01-03 00:42

    There's no big reason behind the difference. I just wanted foo to be behave like foo(), if there's no local variable foo in the scope. I thought it was useful for creating DSL etc. But I saw no reason to make Foo to behave like Foo().

提交回复
热议问题