diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-17 14:09:43 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-17 14:09:43 +0000 |
commit | 23f6b5bdc450abc5ce3a3dc7540a668f5d166dea (patch) | |
tree | 15669c34dd56e1950250456735eaa35d7cd4b5a3 /ext/enumerator/enumerator.txt | |
parent | a7ddb2e342a909cef7d1a73fcc1d0ba193654e35 (diff) |
* 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
Diffstat (limited to 'ext/enumerator/enumerator.txt')
-rw-r--r-- | ext/enumerator/enumerator.txt | 5 |
1 files changed, 5 insertions, 0 deletions
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) {...} |