From: daz Date: 2005-08-07T22:41:08+09:00 Subject: Re: new block notation (was: Re: ruby-dev summary 26468-26661) Sylvain Joyeux wrote: > You can check that by defining > def each_proc(p) > self.each { |x| p.call(x) } > end You stopped short of giving a working example. Would you confirm or replace this: #------------ puts 'ruby %s (%s)' % [RUBY_VERSION, RUBY_RELEASE_DATE] class Range def each_lamb each { |x| lambda { |y| return y if yield(y) }.call(x) } end def each_pnew each { |x| Proc.new { |y| return y if yield(y) }.call(x) } end end (1..4).each_lamb {|ep| p ep; ep == 3} puts '--' (1..4).each_pnew {|ep| p ep; ep == 3} #------------ #-> ruby 1.8.2 (2004-12-25) #-> 1 #-> 2 #-> 3 #-> 4 #-> -- #-> 1 #-> 2 #-> 3 #------------ Thanks, daz