Module: Enumerable

Defined in:
lib/clacky.rb

Instance Method Summary collapse

Instance Method Details

#filter_map(&block) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/clacky.rb', line 18

def filter_map(&block)
  return to_enum(:filter_map) unless block

  each_with_object([]) do |item, result|
    mapped = block.call(item)
    result << mapped if mapped
  end
end