Skip to content

Files

Latest commit

 

History

History
30 lines (21 loc) · 465 Bytes

Lint-NextWithoutAccumulator.md

File metadata and controls

30 lines (21 loc) · 465 Bytes

Pattern: next without accumulator

Issue: -

Description

Don't omit the accumulator when calling next in a reduce block.

Examples

# bad

result = (1..4).reduce(0) do |acc, i|
  next if i.odd?
  acc + i
end
# good

result = (1..4).reduce(0) do |acc, i|
  next acc if i.odd?
  acc + i
end

Further Reading