[–] fbcocq 15y ago ↗ I think the speed increase comes from += creating a new string object every time, whereas << literally concatenates it.Programming the hunches and guesses way on the HN frontpage makes me sad.http://ruby-doc.org/core/classes/String.html#M000807str + other_str => new_strConcatenation Returns a new String containing other_str concatenated to str.str << fixnum => str str.concat(fixnum) => str str << obj => str str.concat(obj) => strAppend Concatenates the given object to str. If the object is a Fixnum between 0 and 255, it is converted to a character before concatenation.
1 comment
[ 2.2 ms ] story [ 12.2 ms ] threadProgramming the hunches and guesses way on the HN frontpage makes me sad.
http://ruby-doc.org/core/classes/String.html#M000807
str + other_str => new_str
Concatenation Returns a new String containing other_str concatenated to str.
str << fixnum => str str.concat(fixnum) => str str << obj => str str.concat(obj) => str
Append Concatenates the given object to str. If the object is a Fixnum between 0 and 255, it is converted to a character before concatenation.