After doing some benchmarking, it looks like delete is about 19% faster than tr when removing characters from a string.
test_string = "this is the test string"
Benchmark.ips do |x|
x.report("tr") do
test_string.tr(" ", "")
end
x.report("delete") do
test_string.delete(" ")
end
end
After doing some benchmarking, it looks like
delete
is about 19% faster thantr
when removing characters from a string.