ruby ittereat array code example
Example 1: ruby loop through array
numbers = [0, 1, 2, 3]
for element in numbers do
puts element
end
Example 2: ruby iterate over array
# For Ruby
arr = ['a', 'b', 'c']
arr.each do |item|
puts item
end
numbers = [0, 1, 2, 3]
for element in numbers do
puts element
end
# For Ruby
arr = ['a', 'b', 'c']
arr.each do |item|
puts item
end