Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: Brian Candler Newsgroups: comp.lang.ruby Subject: Re: anonymous closures with Proc,new, lambda and -> Date: Tue, 19 Apr 2011 13:19:04 -0500 Organization: Service de news de lacave.net Lines: 35 Message-ID: References: <03b15245deb79f0148cf821c34a7ed41@ruby-forum.com> NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1303237164 52784 65.111.164.187 (19 Apr 2011 18:19:24 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Tue, 19 Apr 2011 18:19:24 +0000 (UTC) In-Reply-To: <03b15245deb79f0148cf821c34a7ed41@ruby-forum.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: 381867 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:3184 7stud -- wrote in post #993798: > Where does this syntax come from? > > closed = Proc.new(over=0){over+=1} It's invalid in 1.8: >> Proc.new(0) {} ArgumentError: wrong number of arguments (1 for 0) from (irb):2:in `initialize' from (irb):2:in `new' from (irb):2 from :0 But accepted in 1.9.2: >> Proc.new(0) {} => # Seems to be undocumented, like much of ruby 1.9. http://ruby-doc.org/core/classes/Proc.html I can't see any obvious purpose for these args: irb(main):006:0> c = Proc.new(1,2,3) { |x,y,z| p x,y,z } => # irb(main):007:0> c.call(5) 5 nil nil => [5, nil, nil] -- Posted via http://www.ruby-forum.com/.