fix variable name typo

This commit is contained in:
ksss
2014-03-15 00:45:58 +09:00
parent 9447c637a5
commit 0bb7f5e950
2 changed files with 16 additions and 1 deletions
@@ -206,7 +206,7 @@ class Enumerator
# # => foo:2
#
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|
yield [i,object]
@@ -72,6 +72,21 @@ assert 'Enumerator#with_object' do
assert_equal([55, 3628800], ret)
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
e = (0..10).each
assert_equal("#<Enumerator: 0..10:each>", e.inspect)