ruby - block syntax difference causes "LocalJumpError: no block given (yield)" -
this question has answer here:
saw strange case come up, trying figure out happening here:
> def test > p yield > end => nil > test { 1 } 1 => 1 > p test { 1 } 1 1 => 1 > p test > 1 > end localjumperror: no block given (yield)
the parser recognizes this
p test 1 end as this
(p test) 1 end the block passed result of p test, not test. therefore, yield can't yield , raises error.
Comments
Post a Comment