Skip to content

CAT 024

unurgunite edited this page Jul 11, 2026 · 3 revisions

CAT-024 — keys/values.map → each_key/each_value

Severity: infoConfidence: highAuto-fix:

Description

keys/values.map → each_key/each_value — Use each_key/each_value with a block instead of .keys.map/.values.map to avoid intermediate arrays.

Bad code

hash.keys.map { |k| k.to_s }
hash.values.map { |v| v * 2 }

Benchmark

Note

See bench results at bench/cat-024/

Clone this wiki locally