Just a little note about memory management in Ruby. Sure, Ruby has a garbage collection scheme that takes care of memory for us, but that doesn't mean we should just litter willy-nilly.
The += operation does not update mutable objects in-place, and the + operator evaluates each side before adding them. That means that this snippet:
s = "foo"
('a'..'z').each do |x|
s += "foo:" + x
end
creates a lot of unnecessary string litter. Three times as much as if we used the << operator:
s = "foo"
('a'..'z').each do |x|
s << "foo:" << x
end
About 79 standard library files show evidence of using += or + with strings, and most cases (if not all) could be probably be replaced with << for a more memory efficient standard code base.