Class: Enumerator::Lazy

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/lazy.rb

Instance Method Summary collapse

Instance Method Details

#compactObject

Create a lazy compact similar to Array#compact.


4
5
6
# File 'lib/ext/lazy.rb', line 4

def compact
  select { |i| !i.nil? }
end

#uniqueObject

Return only my unique elements


9
10
11
# File 'lib/ext/lazy.rb', line 9

def unique
  Set.new(self).each
end