Skip to content

Commit

Permalink
Refer to already existing example
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Apr 17, 2024
1 parent 8368de5 commit ec7d686
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions docs/modules/ROOT/pages/cops_performance.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1170,9 +1170,8 @@ This cop identifies places where `map { ... }.compact` can be replaced by `filte
=== Safety
This cop's autocorrection is unsafe because `map { ... }.compact` might yield
different results than `filter_map`. For example, `[true, false, nil].compact`
gives `[true, false]`, while `[true, false, nil].filter_map(&:itself)` results in
`[true]`, i.e. `filter_map` also filtered out falsy values.
different results than `filter_map`. As seen in the example above, `filter_map`
also filters out falsy values, while `compact` only gets rid of `nil`.
=== Examples
Expand Down

0 comments on commit ec7d686

Please sign in to comment.