Class: Enumerator::Lazy

Inherits:
Object show all
Defined in:
lib/coroutines.rb

Instance Method Summary collapse

Instance Method Details

#filter_mapObject

:call-seq:

enum.filter_map {|obj| block }  -> an_enumerator

Returns a new lazy Enumerator which iterates over all non-nil values returned by block while obj iterates over enum. – taken from the API doc of Enumerator::Lazy.new



51
52
53
54
55
56
# File 'lib/coroutines.rb', line 51

def filter_map
	Lazy.new(self) do |yielder, *values|
		result = yield *values
		yielder << result if result
	end
end