摘要:
$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
阅读(650)
评论(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
阅读(1066)
评论(0)
推荐(0)

浙公网安备 33010602011771号