访问次数
我的另一个总结性博客: todototry 大米粒
摘要: $res = "__"def lamb(&lamb) 3.times do puts $res=lamb.call end puts "-------at the end of lamb() : #{$res}"enddef lamb_test lamb { return puts " return in lamb() " } puts "--------at the lamb_test() end"enddef bl 3.times do puts $res= yield end puts " 阅读全文
posted @ 2011-08-14 17:01 fandyst 阅读(639) 评论(1) 推荐(0) 编辑
摘要: Ruby 之 Block, Proc, LambdaBlockBlock 不是对象,是Ruby的语言特性,近似于闭包(Closure)。范例:def meth res= yield "Block called returns #{res}"endputs methdo next “next_value” end #Block called returns next_valueputs methdo break “break_value” end # break_vcowcuo错误哦aluedef my methdo return “reutnr_value” endendp 阅读全文
posted @ 2011-08-14 14:01 fandyst 阅读(1045) 评论(0) 推荐(0) 编辑