Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news.musoftware.de!wum.musoftware.de!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: 7stud -- Newsgroups: comp.lang.ruby Subject: Re: Scope problem (?) in implementing Design Patterns in Ruby Date: Fri, 13 May 2011 12:50:13 -0500 Organization: Service de news de lacave.net Lines: 30 Message-ID: <4bc0d1972260442c6d44caba7e6eefaf@ruby-forum.com> References: <7e6155b0-8d33-4677-87ec-be2c3f0fca97@b7g2000prg.googlegroups.com> <2ac328808edcaa956da4f286617acefb@ruby-forum.com> <4bfa1e5a3794daf70f5171094052dab0@ruby-forum.com> <9307dd9ab066746e74f5cbc1f8d02bbf@ruby-forum.com> <1a2fe490-3ad8-4c68-b1c2-2db31012a1a3@f31g2000pri.googlegroups.com> <5e7178b8-0f8c-4039-b43c-be0c350c0b58@dn9g2000vbb.googlegroups.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1305309048 53094 65.111.164.187 (13 May 2011 17:50:48 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Fri, 13 May 2011 17:50:48 +0000 (UTC) In-Reply-To: <5e7178b8-0f8c-4039-b43c-be0c350c0b58@dn9g2000vbb.googlegroups.com> X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 383220 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: <4bc0d1972260442c6d44caba7e6eefaf@ruby-forum.com> Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:4504 RichardOnRails wrote in post #998460: > > I have only one question: I put a space between the & and the method > following it; the code broke. Is the construct you used documented on- > line somewhere? I've peeked at lambda documentation so I've got the > drift but I haven't used it in any of my code so far. > Your bible, "The Well-Grounded Rubyist" uses the &:meth_name construct a lot, and David Black says that the '&' in '&:meth_name' does two things: 1) It calls the specified object's to_proc() method. And Symbol#to_proc is defined like this: class Symbol def to_proc proc{|obj, *args| obj.send(self, *args)} #self=:meth_name end end That just creates a function that takes an object as an argument and sends() the :meth_name to the object, i.e. the function calls the :meth_name method on the object. 2) The '&' tells ruby to convert the Proc to a block. -- Posted via http://www.ruby-forum.com/.