how to display my outcome in a loop of an array in ruby code example
Example 1: ruby for loop
for element in array do
element.do_stuff
end
Example 2: ruby iterate over array
# For Ruby
arr = ['a', 'b', 'c']
arr.each do |item|
puts item
end
for element in array do
element.do_stuff
end
# For Ruby
arr = ['a', 'b', 'c']
arr.each do |item|
puts item
end