summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-enumerator
diff options
context:
space:
mode:
authorksss <[email protected]>2016-12-01 15:32:29 +0900
committerksss <[email protected]>2016-12-01 16:13:24 +0900
commit2718fed1248872e6af436159a8f336fb54b86df2 (patch)
tree3bcff566bb5021c8ef5e185f45ef58e854df5335 /mrbgems/mruby-enumerator
parent0f774ff4dfc168aa90764b0130d60f14b837cc53 (diff)
downloadmruby-2718fed1248872e6af436159a8f336fb54b86df2.tar.gz
mruby-2718fed1248872e6af436159a8f336fb54b86df2.zip
Support svalue
Diffstat (limited to 'mrbgems/mruby-enumerator')
-rw-r--r--mrbgems/mruby-enumerator/mrblib/enumerator.rb4
-rw-r--r--mrbgems/mruby-enumerator/test/enumerator.rb3
2 files changed, 5 insertions, 2 deletions
diff --git a/mrbgems/mruby-enumerator/mrblib/enumerator.rb b/mrbgems/mruby-enumerator/mrblib/enumerator.rb
index 694ad4270..89b66cd45 100644
--- a/mrbgems/mruby-enumerator/mrblib/enumerator.rb
+++ b/mrbgems/mruby-enumerator/mrblib/enumerator.rb
@@ -162,9 +162,9 @@ class Enumerator
end
n = offset - 1
- enumerator_block_call do |i|
+ enumerator_block_call do |*i|
n += 1
- yield [i,n]
+ yield i.__svalue, n
end
end
diff --git a/mrbgems/mruby-enumerator/test/enumerator.rb b/mrbgems/mruby-enumerator/test/enumerator.rb
index 2e45dae4b..e86e874f0 100644
--- a/mrbgems/mruby-enumerator/test/enumerator.rb
+++ b/mrbgems/mruby-enumerator/test/enumerator.rb
@@ -50,6 +50,9 @@ end
assert 'Enumerator#with_index' do
assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).with_index.to_a)
assert_equal([[1,5],[2,6],[3,7]], @obj.to_enum(:foo, 1, 2, 3).with_index(5).to_a)
+ a = []
+ @obj.to_enum(:foo, 1, 2, 3).with_index(10).with_index(20) { |*i| a << i }
+ assert_equal [[[1, 10], 20], [[2, 11], 21], [[3, 12], 22]], a
end
assert 'Enumerator#with_index nonnum offset' do