Answers for "for loop ruby"

6

ruby for loop

for i in 0..2 do 
  print(i)
end

# => 0
# => 1
# => 2
Posted by: Guest on June-17-2020
3

ruby for loop

for element in array do
  element.do_stuff
end
Posted by: Guest on May-29-2020
1

for loop ruby

# You can use an each to mimic the functionality of a for loop

(0..5).each do |i|
  puts "Inside loop i = #{i}"
  # put your code for loop here
end

# outputs 
# Inside loop i = 0   
# Inside loop i = 1
# Inside loop i = 2
# Inside loop i = 3
# Inside loop i = 4
# Inside loop i = 5
Posted by: Guest on October-25-2020

Browse Popular Code Answers by Language