From: Eric Hodel Date: 2007-11-17T12:19:20+09:00 Subject: Re: "&prock", not "&block" On Nov 16, 2007, at 02:01 , Greg Weeks wrote: > Eric Hodel wrote: >>> It may be that "&foo" is pedagogically described as the "foo" >>> parameter with an "&" modifier. But that is misleading. >> >> This is correct, and this is what happens. Its not misleading. > > I take your point. Thanks for the correction. > > Nevertheless, even though the argument is a block, the parameter > foo is > not. If you want to use the *block* argument in the method body, you > use the expression &foo, not foo. If by 'use the block argument in the method body' you mean 'call methods on the block argument', you must use 'foo', as '&foo.some_method' is a syntax error. If by 'use [...]' you mean 'pass foo as a block argument to another method' (like the array- splat * syntax) you are correct. > foo is a proc; &foo -- an expression, not a parameter as I > erroneously said -- is a block. &foo is not an expression, & can only be used to modify argument passing: $ ruby def x(&foo) &foo end -:1: parse error def x(&foo) &foo end ^ def x(&foo) (&foo) end -:2: parse error def x(&foo) (&foo) end ^ -- Poor workers blame their tools. Good workers build better tools. The best workers get their tools to do the work for them. -- Syndicate Wars