摘要: Block,lambda,Proc要好好理解下,在Ruby中很重要。Block块就是一个匿名函数,被调用的方法调用,在调用的方法里面通过field调用。Block主要用于迭代。Ruby代码 :arr = [1,2,3,4,5]arr.each{|item| puts item}Proc也是一个代码块,相当于过程吧Ruby代码 :a_proc = Proc.new {|a, *b| b.collec... 阅读全文
posted @ 2010-05-17 13:26 chunchill 阅读(809) 评论(0) 推荐(0) 编辑