Цикл each_with_index

Поток управления / Циклы

nums = [1, 2, 3, 4, 5]
nums.each_with_index{|i, v| 
    puts "nums[#{i}] = #{v}"
}