Chinaunix首页 | 论坛 | 博客
  • 博客访问: 510497
  • 博文数量: 100
  • 博客积分: 2058
  • 博客等级: 大尉
  • 技术积分: 1029
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-14 23:29
文章分类
文章存档

2011年(94)

2010年(6)

分类:

2010-07-21 00:02:17

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"



阅读(4500) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~