11 . why didn't he print 1112131415 only ? why did he print [1,2,3,4,5]


#1


#2

If we write it a slightly different, we get a different printout:

array = [1,2,3,4,5]

array.each do |x|
  x += 10
  puts "#{x}"
end
puts "Done!"

Output

11
12
13
14
15
Done!
nil

The array in your example is still in the buffer when the interpreter finishes running. It is normal behavior for the console to echo the buffer contents. If there is nothing in the buffer at completion, it prints nil.

Normal behavior that can be ignored. It is not your code that is causing it.