Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 520 Bytes

Performance-SelectMap.md

File metadata and controls

24 lines (15 loc) · 520 Bytes

Pattern: Use of select.map instead of filter_map

Issue: -

Description

In Ruby 2.7, Enumerable#filter_map has been added.

This rule identifies places where select.map can be replaced by filter_map.

Examples

# bad
ary.select(&:foo).map(&:bar)
ary.filter(&:foo).map(&:bar)

# good
ary.filter_map { |o| o.bar if o.foo }

Further Reading