Procオブジェクト生成方法の3種盛り合わせ
メタプロより。
inc = Proc.new { |x| x+1} p inc.class p inc.call(33) dec = lambda { |x| x-1} p dec.class p dec.call(33) def fuga(&the_proc) the_proc end mul = fuga{|x, y| x*y} p mul.class p mul.call(4,5)
結果
Proc 34 Proc 32 Proc 20
3番目の方法は知らなかった。