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

前端 未结 8 784
小蘑菇
小蘑菇 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 22:04

    Note that the convention is:

    Class#method
    

    rather than

    object#method
    

    In code you would have object.method, if object was an instance of class. The # convention is not used in code.

    From the RDoc documentation:

    Use :: for describing class methods, # for describing instance methods, and use . for example code.

提交回复
热议问题