Method: Enumerator#uniq

Defined in:
lib/ext/enumerator.rb

#uniqEnumerator

Thanks to u/0x0dea for the lazy implementation.

Returns:

See Also:

Author:

  • u/0x0dea



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