From: Eric Hodel Date: 2006-02-21T04:07:51+09:00 Subject: Re: Unexpected syntax error On Feb 19, 2006, at 4:10 PM, Daniel Harple wrote: > $ ruby -v > ruby 1.8.4 (2005-12-24) [powerpc-darwin8.3.0] > > # Example to illustrate the problem > def foo1 > p (1..10).method(:each) > end > > def foo2() > p((1..10).method(:each)) > end > > def foo3() > p (1..10).method(:each) > end > > foo1 # -> No error > foo2 # -> No error > foo3 # -> Error Ruby thinks those are argument parentheses. This may not be a bug. -:11: warning: don't put space before argument parentheses # # 1..10 -:11:in `method': undefined method `each' for class `NilClass' (NameError) from -:11:in `foo3' from -:16 $ parse_tree_show -f p (1..10).method(:each) (eval):1: warning: (...) interpreted as grouped expression [[:class, :Example, :Object, [:defn, :example, [:scope, [:block, [:args], [:fcall, :p, [:array, [:call, [:lit, 1..10], :method, [:array, [:lit, :each]]]]]]]]]] -- Eric Hodel - drbrain@segment7.net - http://segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com