You can always just modify each value in-place:
customers.each { |c| c.gsub!(/\./, ' ') }
The alternatives, like collect!
are more appropriate when you're switching the kind of object, not just altering the content of an existing object.
Note that this will mangle the original input, so if the String values in customers
are frozen or need to be preserved in their initial form this won't work. This is probably not the case, but it is important to keep this in mind.
Update: After some benchmarking I've come to the conclusion that the fastest way to perform this operation is:
customers.each { |c| c.tr!('.', ' ') }
For those that are curious, here's a benchmark scaffold to experiment with.
# user system total real
# 0.740000 0.020000 0.760000 ( 0.991042)
list.each { |c| c.gsub!(/\./, ' ') }
# 0.680000 0.010000 0.690000 ( 1.011136)
list.collect! { |c| c.gsub(/\./, ' ') }
# 0.490000 0.020000 0.510000 ( 0.628354)
list.collect!{ |c| c.split('.').join(' ') }
# 0.090000 0.000000 0.090000 ( 0.103968)
list.collect!{ |c| c.tr!('.', ' ') }