I would like to add an element to an array but without actually changing that array and instead it returning a new one. In other words, I want to avoid:
arr = [1,2]
arr << 3
You can easily add two arrays in Ruby with
plus operator. So, just make an array out of your element.
arr = [1, 2] puts arr +  # => [1, 2, 3] puts arr # => [1, 2]