diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-09-27 00:04:34 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-09-27 00:04:34 +0900 |
| commit | 0aa83c503d15d5683f2135d172a02f155498c598 (patch) | |
| tree | 46b01333e5ea8a4052f84f979996994a84f1116b /mrbgems/mruby-enum-ext | |
| parent | 524a038876657a9cb062ec1e27015662e648d45f (diff) | |
| download | mruby-0aa83c503d15d5683f2135d172a02f155498c598.tar.gz mruby-0aa83c503d15d5683f2135d172a02f155498c598.zip | |
Enumerable#each_{cons,slice} to return enumerators
Diffstat (limited to 'mrbgems/mruby-enum-ext')
| -rw-r--r-- | mrbgems/mruby-enum-ext/mrblib/enum.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/mrbgems/mruby-enum-ext/mrblib/enum.rb b/mrbgems/mruby-enum-ext/mrblib/enum.rb index 6fef0c077..d469f0651 100644 --- a/mrbgems/mruby-enum-ext/mrblib/enum.rb +++ b/mrbgems/mruby-enum-ext/mrblib/enum.rb @@ -116,6 +116,7 @@ module Enumerable raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int) raise ArgumentError, "invalid size" if n <= 0 + return to_enum(:each_cons,n) unless block ary = [] n = n.to_int self.each do |*val| @@ -143,6 +144,7 @@ module Enumerable raise TypeError, "no implicit conversion of #{n.class} into Integer" unless n.respond_to?(:to_int) raise ArgumentError, "invalid slice size" if n <= 0 + return to_enum(:each_slice,n) unless block ary = [] n = n.to_int self.each do |*val| |
