设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3015|回复: 2
打印 上一主题 下一主题

[已经解决] 一个def没有具体写明属于哪个class的话这个def属于哪个class呢?

[复制链接]

Lv5.捕梦者 (版主)

梦石
1
星屑
23963
在线时间
3338 小时
注册时间
2011-7-8
帖子
3925

开拓者

1
发表于 2021-5-5 22:34:53 | 显示全部楼层
本帖最后由 guoxiaomi 于 2021-5-5 22:36 编辑

https://bparanj.gitbooks.io/ruby ... he_main_object.html

The methods defined at the top level becomes private method in the Object. This shows that these methods are bound to the main object.

RUBY 代码复制
  1. def function666(x);end
  2.  
  3.  
  4. p method(:function666) #=> #<Method: main.function666>
  5. p method(:function666).owner #=> Object
  6.  
  7. p self.private_methods.include?(:function666) #=> true
  8. p Object.private_methods.include?(:function666) #=> true

评分

参与人数 2星屑 +50 +1 收起 理由
RyanBern + 50 认可答案
taeckle + 1 多谢大神!

查看全部评分

熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-6-12 06:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表