Loops
while, until, loop do, times, upto and step repeat code.
Example
3.times { |i| print i, " " }
puts
1.upto(3) { |i| print i }
puts
10.step(1, -4) { |i| print i, " " }
puts
i = 0
i += 1 while i < 5
puts iResult
0 1 2 123 10 6 2 5
Exercise
Repeat n times.
3. { }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.