each_with_index 循环

控制流 / 循环

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