From: David Smiley Date: 2006-02-28T02:05:17+09:00 Subject: parser bug, function call without parens across multiple lines I have encountered a counter-intuitive bug in Ruby's parser. The following sample shows the problem: puts Class.new do def to_s 'no bug' end end.new What do you think the output should be? I think it should clearly be 'no bug' but instead it is '#' and then an error complaining that there is no method 'new' on 'NilClass'. See, Ruby invokes the call to 'new' AFTER the call to puts. To work around this problem, use of parenthesis are necessary. This problem is NOT there if the code is on one line: puts Class.new {def to_s ; 'no bug'; end }.new The fact that this shows up for the multiple line but not the single line sample should be a sign that there is indeed a problem. And it doesn't matter whether the brackets or do-end notation is used; the results are the same. I encountered this problem when I was using Rails to set the around_filter of a controller by using an anonymous class. I tested this against Ruby 1.8.4. ~ David Smiley MITRE