Skip to content

Commit 3b729ad

Browse files
author
Alex P Davydow
committed
Uniq! works in more predictable way if each will be run twice for the
final object
1 parent f1913da commit 3b729ad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/lazy_enumerable.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ def each(&output_block)
9797

9898
def uniq!
9999
@enum = self.clone
100-
@done = {}
101100
self.singleton_class.class_eval do
102101
def each(&output_block)
102+
done = {}
103103
@enum.each do |e|
104-
(output_block[e]; @done[e]=true) unless @done[e]
104+
(output_block[e]; done[e]=true) unless done[e]
105105
end
106106
self
107107
end

0 commit comments

Comments
 (0)