Unverified Commit 2718fed1 authored by ksss's avatar ksss

Support svalue

parent 0f774ff4
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment