u16suzuの blog

日々学んだことのメモブログです。

2つの proc を合成して1つの proc にする

# 2つの proc を合成して1つの proc にする
def foo(arg1, arg2)
  Proc.new do
    arg1.call
    arg2.call
  end
end

p1 = Proc.new { p 123}
p2 = Proc.new { p 456}

res = foo( p1, p2 )
res.call
# => 123\n456