Why does this code 'lock up' ruby? And what is the best way to get past it? I posted my solution below. Is there another way to do this? Thanks in advance!
Code:
nums = [1, 2, 3]
nums.each { |i| nums << i + 1 }
My solution:
nums = [1, 2, 3]
adjustments = []
nums.each { |i| adjustments << i + 1 }
nums += adjustments