Possible Duplicate:
for vs each in Ruby
Let's say that we have an array, like
sites = %w[stackoverflow stackexchange serverfault]
What's the difference between
for x in sites do
puts x
end
and
sites.each do |x|
puts x
end
?
They seem to do the same exact thing, to me, and the syntax of the for
loop is clearer to me. Is there a difference? In what situations would this be a big deal?