String Concatenation in Ruby

There are various ways that you can do string concatenation in Ruby:

1- Concatenate using “+” operator

2- Concatenate without the “+” operator

3- Concatenate using “<<” operator

4- Concatenate using “concat” method

5- Create an array of strings and use “join” method

Check out the links below for some string concatenation performance comparisons:

http://stackoverflow.com/questions/4402336/ruby-array-join-versus-string-concatenation-efficiency

http://stackoverflow.com/questions/377768/string-concatenation-in-ruby

https://coderwall.com/p/ac5j9g/or-concat-what-is-faster-for-appending-string-in-ruby

Hope this helps.
Good Luck,
Serdar

Leave a Reply

Your email address will not be published. Required fields are marked *