ruby for loop array strings 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 strings
input = 'abcdef' chars = input.split('')puts chars.lengthputs chars[2]puts chars.each { |c| puts c}