(Ruby1.9.3)
def foo(a) yield a end puts foo(10) {|x| x * 2} # >> 20 def bar(option) yield option end puts bar(a: 2, b: 3) { |o| o[:a] + o[:b] + 10 } # >> 15
牌語備忘録 -pygo
(Ruby1.9.3)
def foo(a) yield a end puts foo(10) {|x| x * 2} # >> 20 def bar(option) yield option end puts bar(a: 2, b: 3) { |o| o[:a] + o[:b] + 10 } # >> 15