Skip to content

Commit 352d5f0

Browse files
makenowjustAry Borenszweig
authored and
Ary Borenszweig
committedDec 23, 2016
Iterator::Flatten#rewind returns iterator itself
1 parent 0dfd469 commit 352d5f0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed
 

Diff for: ‎spec/std/iterator_spec.cr

+7
Original file line numberDiff line numberDiff line change
@@ -632,5 +632,12 @@ describe Iterator do
632632
iter.next.should eq(7)
633633
iter.next.should be_a(Iterator::Stop)
634634
end
635+
636+
it "return iterator itself by rewind" do
637+
iter = [1, [2, 3], 4].each.flatten
638+
639+
iter.to_a.should eq([1, 2, 3, 4])
640+
iter.rewind.to_a.should eq([1, 2, 3, 4])
641+
end
635642
end
636643
end

Diff for: ‎src/iterator.cr

+1
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ module Iterator(T)
448448
@generators << @iterator
449449
@stopped.each &.rewind
450450
@stopped.clear
451+
self
451452
end
452453

453454
def self.element_type(element)

0 commit comments

Comments
 (0)
Please sign in to comment.