From: Mauricio Fernandez Date: 2006-08-25T03:43:57+09:00 Subject: Re: do not understand this closure On Fri, Aug 25, 2006 at 03:27:10AM +0900, ara.t.howard@noaa.gov wrote: > On Fri, 25 Aug 2006, rak rok wrote: > > >Is there any way to have a proc object be callable identically to a method, > >ie with the parentheses? Is there a reason to keep the notation distinct? > > > >Thanks, > >-rr- > > harp:~ > cat a.rb > def the_method() 'namespace one' end > > the_method = String.new 'namespace two' > > p the_method() > p the_method > > > harp:~ > ruby a.rb > "namespace one" > "namespace two" > > that said, 1.9 has support for a_proc() This used to work: $ cat proc.rb a = proc{|x| p x} (a)(1) ... but doesn't anymore. $ ruby19 -v proc.rb ruby 1.9.0 (2006-08-13) [i686-linux] proc.rb:2: warning: useless use of a variable in void context proc.rb:2: syntax error, unexpected '(', expecting $end (a)(1) Right now, it's RUBY_RELEASE_DATE # => "2006-08-13" RUBY_VERSION # => "1.9.0" a = proc{|x| x+1} a.(2) # => 3 [gotta update my changelog] -- Mauricio Fernandez - http://eigenclass.org - singular Ruby