run_all(filename)---->run(filename)----->Keyword.run_kw_no_exception(kw)----->run_kw(kw)----->run_kw2(keyword,kw_class,parmlist,parm)--------->instance.send(keyword,nil,parse_keyword2(kw))
ruby中的send方法: 如 对象obj
hello()是对象obj的方法
则 obj.hello()和obj.send(obj)效果是一样的。
下面是ruby帮助文档中对send的解释:
|
obj.send( aSymbol [, args
]* ) -> anObject |
|
Invokes the method identified by aSymbol, passing it any arguments
specified. You can use __send__ if the name send
clashes with an existing method in obj.
class Klass |
def hello(*args) |
"Hello " + args.join(' ') |
end |
end |
k = Klass.new |
k.send :hello, "gentle", "readers" | |
阅读(4567) | 评论(0) | 转发(0) |