summaryrefslogtreecommitdiffhomepage
path: root/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2014-03-18 22:22:23 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2014-03-18 22:22:23 +0900
commit31b2980acb7218b0cc13cbc658208cde641a7ff8 (patch)
treeaceb108fcf20e6a85725950ba632bd44312262d4 /mrblib
parent555c187687d52f0586e0f4665cca41c21d04ab02 (diff)
parent9abe413530431660b274acb7273ef1f1f23771c7 (diff)
downloadmruby-31b2980acb7218b0cc13cbc658208cde641a7ff8.tar.gz
mruby-31b2980acb7218b0cc13cbc658208cde641a7ff8.zip
Merge pull request #1880 from ksss/enum-each_with_index
Enumrable#each_with_index return Enumerator if non block given
Diffstat (limited to 'mrblib')
-rw-r--r--mrblib/enum.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/mrblib/enum.rb b/mrblib/enum.rb
index 5a33ed3c5..04a27294c 100644
--- a/mrblib/enum.rb
+++ b/mrblib/enum.rb
@@ -108,6 +108,8 @@ module Enumerable
#
# ISO 15.3.2.2.5
def each_with_index(&block)
+ return to_enum :each_with_index unless block_given?
+
i = 0
self.each{|*val|
block.call(val.__svalue, i)