Skip to content

CAT 006

unurgunite edited this page Jul 11, 2026 · 3 revisions

CAT-006 — hash.keys.each → each_key

Severity: infoConfidence: highAuto-fix:

Tip

This rule supports auto-fix via --fix

Description

hash.keys.each → each_key — Use each_key instead of .keys.each to avoid allocating an intermediate array of keys.

Bad code

hash.keys.each { |k| ... }

Good code

hash.each_key { |k| ... }

Benchmark

Note

See bench results at bench/cat-006/

Clone this wiki locally