Why are methods in Ruby documentation preceded by a hash sign?

前端 未结 8 782
小蘑菇
小蘑菇 2020-11-30 21:05

When I see any Ruby method printed in text, it usually appears as:

Class#method

or

#method

Now, I would u

8条回答
  •  误落风尘
    2020-11-30 21:57

    The # notation is used to refer to the canonical instance method, like String#upcase. The . notation is used to refer to the method of a particular instance, like mystring.upcase. The distinction is made to not imply that a class method 'upcase' exists.

提交回复
热议问题