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

前端 未结 8 746
小蘑菇
小蘑菇 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:03

    From the rdoc docs (emphasis mine):

    Names of classes, source files, and any method names containing an underscore or preceded by a hash character are automatically hyperlinked from comment text to their description.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题