Skip to content

Commit 5449e03

Browse files
committed
Add extra Array#each spec
1 parent 0bf24bd commit 5449e03

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

spec/ruby/core/array/each_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
iterated.should == [0, 2, 4]
3838
end
3939

40+
it "yields the same element multiple times if inserting while iterating" do
41+
a = [1, 2]
42+
iterated = []
43+
a.each { |x| iterated << x; a.unshift(0) if a.size == 2 }
44+
iterated.should == [1, 1, 2]
45+
end
46+
4047
it "yields each element to a block that takes multiple arguments" do
4148
a = [[1, 2], :a, [3, 4]]
4249
b = []

0 commit comments

Comments
 (0)