[grammarians] do/end vs braces

MenTaLguY mental at rydia.net
Fri Dec 9 01:33:30 EST 2005


On Thu, 2005-12-08 at 14:44 -0800, Terence Parr wrote:
> On Dec 8, 2005, at 7:27 AM, mental at rydia.net wrote:
> > But this will net you a parse error ('2' is not a valid method
> > name):
> >
> >  obj.meth 1, 2 { |i|
> >    puts i
> >  }
> 
> Yikes!  Not sure what's up there.  What does the {...} bind to then?   
> The 2?  If so, why is 2 considered a method.

Binds to the 2, yes.  But then it fails to match, as 2 isn't a method.
It should also fail if there were an lvar rather than a private method
call in that position.

That's an interesting question actually ... how it matches enough to
bind, but not enough to succeed.

-mental
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://rubyforge.org/pipermail/rubygrammar-grammarians/attachments/20051209/4a29d051/attachment.bin


More information about the Rubygrammar-grammarians mailing list