Ruby1.8.7挙動クイズ
以下のコードはそれぞれどのような挙動をするか?
def foo yield end p foo {|&b| b }
def bar &b b.call end p bar {|&b| b }
答え
-:2: tried to create Proc object without a block (ArgumentError) from -:2:in `foo' from -:5
nil
これバグじゃね?
このyieldの不可解な挙動の所為で,
[1,2,3].map {|i, &b| i + 1 }
で例外が飛んでくる.困ったなぁ.