When I use get.chomp and use an array ([1,2]) it outputs to a string ("[1,2]"). I want to change the string to an array so the method can work. How do I do this?
def sum(array)
array.inject(:+)
end
puts("Please enter an array.")
array = gets.chomp
puts sum(array)
=>[1,2]
=>[1,2]