slide43

左のコードを実行したら、下のように出力されるlogメソッド。
{}のブロックは、do...endに置き換えた方が分かるかも。
def foo
log("in foo"){ yield("FOO") }
end
def bar
log("in bar") do
foo do |v|
log("in block for foo"){ yield(v) }
end
end
end
bar do |v|
log("in block for bar"){ v * 3 }
end
in bar before
in foo before
in block for foo before
in block for bar before
in block for bar after
in block for foo after
in foo after
in bar after
=> "FOOFOOFOO"