Neeraj Verma
0
Q:

ruby how to loop through an array

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

arr.each do |item|
  puts item
end
2
numbers = [0, 1, 2, 3]
for element in numbers do
  puts element
end
1
# For Ruby
arr = ['a', 'b', 'c']

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

New to Communities?

Join the community