Commit 0bb7f5e9 authored by ksss's avatar ksss

fix variable name typo

parent 9447c637
...@@ -206,7 +206,7 @@ class Enumerator ...@@ -206,7 +206,7 @@ class Enumerator
# # => foo:2 # # => foo:2
# #
def with_object object def with_object object
return to_enum :with_object, offset unless block_given? return to_enum :with_object, object unless block_given?
each do |i| each do |i|
yield [i,object] yield [i,object]
......
...@@ -72,6 +72,21 @@ assert 'Enumerator#with_object' do ...@@ -72,6 +72,21 @@ assert 'Enumerator#with_object' do
assert_equal([55, 3628800], ret) assert_equal([55, 3628800], ret)
end end
assert 'Enumerator#with_object arguments' do
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
a = []
to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|
a << "#{string}:#{x}"
end
assert_equal ["foo:0","foo:1","foo:2"], a
end
assert 'Enumerator#inspect' do assert 'Enumerator#inspect' do
e = (0..10).each e = (0..10).each
assert_equal("#<Enumerator: 0..10:each>", e.inspect) assert_equal("#<Enumerator: 0..10:each>", e.inspect)
......
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