ruby中的send方法

4606阅读 0评论2010-07-21 lijianweiabcde
分类:

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"



上一篇:什么是“负载均衡“------2010-7-20
下一篇:Alex学Ruby