The string is only a sequence of characters os, <the operator allows you to add a few more characters to this sequence. Some languages have immutable strings, such as Java and C #, others have mutable strings, such as C ++, there is nothing wrong with that, this is what, according to the developers of the language, was necessary.
In Java, when you need to create a large string by combining many smaller strings, you must first use StringBuilder, and then build a real string from it at the end. In Ruby, you can simply continue to use << to add more characters and them to this line.
The main difference is that using <<is much faster than "one_string + other_string" because the + operator generates a new line instead of appending to one_string .
source share