D
Daniel Sheppard
If I'm understanding the change properly, the following code should do
the same thing:
require 'enumerator'
{
=09Array =3D> [:each, :each_index, :reverse_each],
=09Dir =3D> [:each],
=09Hash =3D> [:each],
=09IO =3D> [:each, :each_byte, :each_line],
=09Range =3D> [:each],
=09String =3D> [:each, :each_byte, :each_line, :scan],
=09Struct =3D> [:each],
}.each { |c, ms|
=09ms.each { |m|
=09 c.class_eval(<<-EOF)
=09 alias :__fix_enumerable_#{m} :#{m}
=09 private :__fix_enumerable_#{m}
=09 def #{m} (*args, &block)
=09 if block
=09 __fix_enumerable_#{m}(*args,
&block)
=09 else
=09 enum_for__fix_enumerable_#{m},
*args)
=09 end
=09 end
=09 EOF
=09}
}
p "abcdefg".each_byte.collect { |x| (x+1).chr }.join
=3D> "bcdefgh"
-----Original Message-----
From: (e-mail address removed) [mailto:[email protected]]=20
Sent: Friday, 16 September 2005 7:53 AM
To: ruby-talk ML
Subject: Re: ruby-dev suumary 26862-26956
Hi,
At Fri, 16 Sep 2005 02:38:30 +0900,
Austin Ziegler wrote in [ruby-talk:156292]:
It would be radical change for stable version, at least 1.8.3.
--
Nobu Nakada
#########################################################################=
############
This email has been scanned by MailMarshal, an email content filter.
#########################################################################=
############
the same thing:
require 'enumerator'
{
=09Array =3D> [:each, :each_index, :reverse_each],
=09Dir =3D> [:each],
=09Hash =3D> [:each],
=09IO =3D> [:each, :each_byte, :each_line],
=09Range =3D> [:each],
=09String =3D> [:each, :each_byte, :each_line, :scan],
=09Struct =3D> [:each],
}.each { |c, ms|
=09ms.each { |m|
=09 c.class_eval(<<-EOF)
=09 alias :__fix_enumerable_#{m} :#{m}
=09 private :__fix_enumerable_#{m}
=09 def #{m} (*args, &block)
=09 if block
=09 __fix_enumerable_#{m}(*args,
&block)
=09 else
=09 enum_for__fix_enumerable_#{m},
*args)
=09 end
=09 end
=09 EOF
=09}
}
p "abcdefg".each_byte.collect { |x| (x+1).chr }.join
=3D> "bcdefgh"
-----Original Message-----
From: (e-mail address removed) [mailto:[email protected]]=20
Sent: Friday, 16 September 2005 7:53 AM
To: ruby-talk ML
Subject: Re: ruby-dev suumary 26862-26956
Hi,
At Fri, 16 Sep 2005 02:38:30 +0900,
Austin Ziegler wrote in [ruby-talk:156292]:
=20[ruby-dev:26924] enumerator
Nobuyoshi Nakada made a patch to return Enumerator object when=20
Enumerable method is called without block. It's applied to each or=20
each-like methods in Array, Dir, Hash, IO, Range, String and Struct.
=20
http://www.rubyist.net/~nobu/ruby/enumerator.diff
Um. Any chance of seeing this in Ruby 1.8.x? I'm supposing this is=20
instead of a LocalJumpError.
It would be radical change for stable version, at least 1.8.3.
--
Nobu Nakada
#########################################################################=
############
This email has been scanned by MailMarshal, an email content filter.
#########################################################################=
############