From: ara.t.howard@... Date: 2006-08-25T23:34:38+09:00 Subject: Re: Support for singleton_class() (was Re: Call functions of superclass) On Fri, 25 Aug 2006, Mauricio Fernandez wrote: > On Fri, Aug 25, 2006 at 06:51:45PM +0900, Christian Neukirchen wrote: >> While we are at adding methods, who else would like ot have a method >> that returns the current block, so you can access it without needing >> to declare it in the arguments list? (And likewise for lambda{}, even >> if 1.9 fixes that.) > > Like Proc.new ? > IIRC there were plans to deprecate it in 1.9, so that request seems to go > against the tide of change :) (but it still seems to work, though): > > RUBY_VERSION # => "1.8.5" > RUBY_RELEASE_DATE # => "2006-08-25" > def a; Proc.new.call end > a {1+1} # => 2 > > RUBY_VERSION # => "1.9.0" > RUBY_RELEASE_DATE # => "2006-08-13" > def a; Proc.new.call end > a{1+1} # => 2 i use harp:~ > cat a.rb def foo() b = lambda{|*a| yield *a} if block_given? b[42] if b end foo foo{|n| p n} harp:~ > ruby a.rb 42 -a -- to foster inner awareness, introspection, and reasoning is more efficient than meditation and prayer. - h.h. the 14th dalai lama