参见英文答案 >
Code block passed to each works with brackets but not with ‘do’-‘end’ (ruby)3
看到一个奇怪的情况出来,试图弄清楚这里发生了什么:
看到一个奇怪的情况出来,试图弄清楚这里发生了什么:
> def test > p yield > end => nil > test { 1 } 1 => 1 > p test { 1 } 1 1 => 1 > p test do > 1 > end LocalJumpError: no block given (yield)