On Thu, 18 Sep 2008, Jeff Hodges wrote:

> No, it's a ruby syntax thing.
> 
> This is faaaaake code but demonstrates the problem.
> 
>   while true do
>      [].inject 'a', {|t,s| 'b' }
>   end

It isn't that: the , means the next thing is a parameter, so it
will be a hash if it starts with brace.

http://www.zenspider.com/Languages/Ruby/QuickRef.html#31

is a concise explanation: it is to do with precedence.  I need more
types of bracket to show this, so I'll use square ones for grouping,
like parentheses in maths.

  test = "test"  # This doesn't alter the argument. 
                 # It's just an expression.

  button test {alert "boo!}

  means
  [ button ] [ test {alert "boo"} ]

  but
  button(test) {alert "boo"}

  is 
  [ button test ] [ {alert "boo"} ]

(...erm, that tastes of Tcl... !)
And that quoted string version is essentially the same,
it will treat that as an expression and try to group the
braces with it.

Those really desperate to avoid parentheses can always
take up FORTH programming :-)

        Hugh 

Reply via email to