新手问题 恶补 ruby 基础之----include 和 extend 模块疑问求解

small_fish__ · October 26, 2012 · Last by jjym replied at October 26, 2012 · 2246 hits

众所周知,我们在一个 class 中 include 一个模块的时候,模块方法将作为类实例方法,而 extend 模块的时候,模块方法会作为类方法。但是如果模块中的方法是 self 方法呢?刚试了下,结果如下图: alt text alt text alt text alt text
这样的结果怎么就和结论不一样了呢?作何理解~~~,还有 module 里面的方法平时有写成 self 吗?

楼主,你这样子贴图实在没法看啊,贴到 pastebin 或者 gist 吧 -_-||

#1 楼 @blacktulip 好的,马上做调整~~

irb 可以有语法高亮的,安装一个 gem 就有

等 LZ 学到 singleton_class 就懂了

You need to Sign in before reply, if you don't have an account, please Sign up first.