In my app, I have a textfield in which the user enters something like this
"1,2,3,4"
which gets stored to the database. Now, when I want to use the inner numbers, i have two options:
"1,2,3,4".split(',')
OR
string.scan(/\d+/) do |x|
a << x
end
Both ways i get an array like
["1","2","3","4"]
and then i can use the numbers by calling to_i on each one of them.
Is there a better way of doing this, that converts
"1,2,3" to [1,2,3] and not ["1","2","3"]