Tagged as loop

edit delete favorite
Posted by eric on Oct 09, 2007
These are simple loops in Ruby. First is a loop using the for-each syntax you may be familiar with, second is the much cooler "each" Enumeration that is far cooler and more "pure" (whatever that means).
# for-each loop
for i in list
  # do something with item 'i'
  p i
end

# enumeration loop
list.each do |i|
  # do something with item 'i'
  p i
end
 
Please submit any bugs/features and report abuse. Thanks!
Spacer
Spacer
Spacer
Top Users
Spacer
Top Tags
Spacer