summaryrefslogtreecommitdiffhomepage
path: root/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-03-15 11:35:02 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-03-15 11:35:02 +0900
commitfc75cff14e7d43defb0c99f5bc9d657c0121c4b0 (patch)
tree80aadc6687bf7a61e8e75d46bc50c7b77143ca18 /mrblib
parente893349e95259dd7902048928525e30352478c7d (diff)
parent447764763cd2608cbd47954f98113edd71b5e801 (diff)
downloadmruby-fc75cff14e7d43defb0c99f5bc9d657c0121c4b0.tar.gz
mruby-fc75cff14e7d43defb0c99f5bc9d657c0121c4b0.zip
Merge pull request #1859 from ksss/enumerator
Fix Enumerator
Diffstat (limited to 'mrblib')
-rw-r--r--mrblib/array.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/mrblib/array.rb b/mrblib/array.rb
index 9141146e5..aa50ac181 100644
--- a/mrblib/array.rb
+++ b/mrblib/array.rb
@@ -31,6 +31,8 @@ class Array
#
# ISO 15.2.12.5.11
def each_index(&block)
+ return to_enum :each_index unless block_given?
+
idx = 0
while(idx < length)
block.call(idx)
@@ -46,6 +48,8 @@ class Array
#
# ISO 15.2.12.5.7
def collect!(&block)
+ return to_enum :collect! unless block_given?
+
self.each_index{|idx|
self[idx] = block.call(self[idx])
}