Skip to content
This repository has been archived by the owner on Apr 17, 2020. It is now read-only.

ForLoopCheck

Marco Otte-Witte edited this page Jun 27, 2013 · 2 revisions

This check reports code that uses for loops as in:

for user in @users
  do_something(user)
end

The use of for loops in Ruby is contrary to the language’s basic concept of iterators. The above statement would better be written as:

@users.each do |user|
  do_something(user)
end

Applies to

  • for loops