For Loops

Lesson 23
Author : Afrixi
Last Updated : November, 2017


Table of Content

Code

Copyfor index in 0..5
    puts index
end

5.times do |index|
    puts index
end

lucky_nums = [4, 8, 15, 16, 23, 42]
for lucky_num in lucky_nums
    puts lucky_num
end

lucky_nums.each do |lucky_num|
     puts lucky_num
end