What is the difference between this code:
p arr = [1, 2, 3, 4, 5]
p arr.map! { |a| a + 2 }
and this code?
arr = [1, 2, 3, 4, 5]
new_arr = []
arr.each do |n|
new_arr << n + 2
end
p arr
p new_arr
They both result in the same answer. Are they just two different ways to achieve the same solution or is there a process or application difference?