From: 7stud -- Date: 2009-03-20T19:02:35+09:00 Subject: Re: Passing a named function instead of a code block? James Coglan wrote: > 2009/3/20 7stud -- > >> >> (ArgumentError) >> from r1test.rb:8 >> >> >> Why does ruby make you use the tortured syntax: >> >> &method(:square1) >> >> for a method vs. the easier syntax for a Proc object? > > > > square2 is a variable name (ie. something you've made an assignment to), > it's just a reference to the lambda object. However, square1 is a method > and > Ruby allows calling methods without parens, so 'square1' is actually > interpreted as a method call to square1 with no arguments. Therefore, to > grab a method as an object without calling it, we need to use > method(:square1). Ok. But there is a certain amount of hypocrisy in that explanation Look here: &square1 :square1 In the first expression there is a method call, and in the second there isn't. Yet, you could describe both those lines as: a method name preceded by some symbol. -- Posted via http://www.ruby-forum.com/.