Check out example codes for "ruby loop through array". It will help you in understanding the concepts better.

Code Example 1

numbers = [0, 1, 2, 3]
for element in numbers do
  puts element
end

Code Example 2

array = [1, 2, 3, 4, 5, 6]
array.each { |x| puts x }

Code Example 3

# For Ruby
arr = ['a', 'b', 'c']

arr.each do |item|
  puts item
end

Code Example 4

# For Ruby
arr = ['a', 'b', 'c']

arr.each { |item| puts item }

Learn ReactJs, React Native from akashmittal.com