返回

我什么时候需要单独使用 self.instance_method 和 instance_method?

发布时间:2022-04-21 23:34:51 206

我希望有人能解释为什么我从这两种方法中得到相同的行为,以及何时使用或不使用 self.

def my_instance_method(arg)
  {do a thing} if another_instance_method_of_same_class?(arg)

看起来和我的行为完全一样

def my_instance_method(arg)
  {do a thing} if self.another_instance_method_of_same_class?(arg)

如果我的搜索技巧不符合标准杆数,但我无法找到这个问题的确切答案,我只会解释自己做了什么(这让我觉得我需要它)。我使用的是最新版本的Ruby。非常感谢。

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
相关帖子