From 23f6b5bdc450abc5ce3a3dc7540a668f5d166dea Mon Sep 17 00:00:00 2001 From: knu Date: Fri, 17 Oct 2003 14:09:43 +0000 Subject: * ext/enumerator/enumerator.c, ext/enumerator/enumerator.txt: Provide Kernel#to_enum as an alias for Kernel#enum_for. Maybe this is a better name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/enumerator/enumerator.txt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ext/enumerator/enumerator.txt') diff --git a/ext/enumerator/enumerator.txt b/ext/enumerator/enumerator.txt index 9a0f93a58e..64c7d50226 100644 --- a/ext/enumerator/enumerator.txt +++ b/ext/enumerator/enumerator.txt @@ -38,6 +38,7 @@ Methods: Requiring this module also adds some methods to the Object class: + to_enum(method = :each, *args) enum_for(method = :each, *args) Returns Enumerable::Enumerator.new(self, method, *args). @@ -48,6 +49,10 @@ Requiring this module also adds some methods to the Object class: enum = str.enum_for(:each_byte) a = enum.map {|b| '%02x' % b } #=> ["78", "79", "7a"] + # protects an array from being modified + a = [1, 2, 3] + some_method(a.to_enum) + And the Enumerable module. each_slice(n) {...} -- cgit v1.2.3