1
下面是一个例子:哪里()在instance_eval的定义Ruby的存储方法
class MyClass
end
obj = MyClass.new
obj.instance_eval do
def hello
"hello"
end
end
obj.hello
# => "hello"
obj.methods.grep "hello"
# => ["hello"]
MyClass.instance_methods.grep "hello"
# => []
MyClass的的实例方法不包含“你好”的方法,所以我的问题是在哪里红宝石存储(在instance_eval的定义的方法)?
第一次确定是否有错字? – lucapette 2012-02-23 22:49:05