From: Arlen Christian Mart Cuss Date: 2007-11-10T09:39:46+09:00 Subject: Re: odd error Hi, On Sat, 2007-11-10 at 08:19 +0900, Bob Hutchison wrote: > On 9-Nov-07, at 6:13 PM, Roger Pack wrote: > > > irb(main):006:0> {}.merge {:a => 3} > > SyntaxError: compile error > > (irb):6: syntax error, unexpected tASSOC, expecting '}' > > {}.merge {:a => 3} > > > > ??? > > {}.merge({:a => 3}) works, though. Is this a grammar problem? > > > Ambiguity I guess. > > It is taking the {:a => 3} as a block rather than as a hash argument > (merge is defined to allow that). The parenthesis resolves the > ambiguity. Right. "=>" is the tASSOC that ruby's talking about. Since it thought you were having a block there, the only valid thing you could have after :a would be an end of block (i.e. :a is your return value). > Cheers, > Bob Arlen