online each loop ruby code example
Example 1: iterate over array ruby
# For Ruby
arr = ['a', 'b', 'c']
arr.each { |item| puts item }
Example 2: ruby for loop
for element in array do
element.do_stuff
end
# For Ruby
arr = ['a', 'b', 'c']
arr.each { |item| puts item }
for element in array do
element.do_stuff
end