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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -