Method: Enumerator#uniq
- Defined in:
- lib/ext/enumerator.rb
#uniq ⇒ Enumerator
Thanks to u/0x0dea for the lazy implementation.
14 15 16 17 18 19 20 |
# File 'lib/ext/enumerator.rb', line 14 def uniq cache = Set.new Lazy.new(self) do |yielder, value| yielder << value if cache.add?(value) end end |