Minor alternative syntax:

def foo
  [a,b] # removed return
end
foo[1]

and

def foo x
  [a,b] # replaced ...
end
foo [1] # same as foo([1]), note: ruby 1.8.1-15 issues "warning: parenthesize 
argument(s) for future version"

Sincerely,
Brian Watt

Terence Parr wrote:

>Howdy,
>
>What does
>
>foo [1]
>
>parse as?  foo could be a variable and then foo is a simple array var:
>
>foo = [a,b]
>foo[1]
>
>If foo is a method, it could return an array and then you could  
>access the 1st element:
>
>def foo
>   return [a,b]
>end
>foo[1]
>
>It could also be a method with args:
>
>def foo x
>...
>end
>foo [1] # same as foo([1])
>
>This 5x ways to do anything syntax is truly a burden for the  
>implementor (and as a user one of the reasons I hated perl).   
>Regardless, is this a true *syntactic* ambiguity as I suspect? I.e.,  
>you need to simply pick an interpretation by dictum in the manual?
>
>Thanks,
>Ter
>
>_______________________________________________
>Rubygrammar-grammarians mailing list
>[email protected]
>http://rubyforge.org/mailman/listinfo/rubygrammar-grammarians
>
>
>  
>

_______________________________________________
Rubygrammar-grammarians mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rubygrammar-grammarians

Reply via email to