Difference between . and #

后端 未结 3 1008
抹茶落季
抹茶落季 2020-12-23 20:37

In Ruby what is the difference between those two (in code):

  • Class.method
  • Class#method
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 21:22

    Class#method is not valid code. It is only used in documentation. method should be an instance method.

    Class.method or object.method is the actual method belonging to the object. Class is an object too. It is valid code.

提交回复
热议问题