Concatenating multi-line strings in ruby

I enjoy ThoughtBot's TIL (today I learned) and I'm doing some of the same when I come across something I haven't before.

Today's item that I learned was that you can concatenate strings in ruby with the backslash '' at the end of the line.

I've always thought that I needed to concatenate strings with a '+' at the end of the line. I'm a *nix person and I've always known about the '' at the end of the line for multi line commands, but never thought about that in Ruby.

I do most of my development in Vim and I have rubocop hooked up so that I can learn how to write better code. This was one of those things that Rubocop spotted and I looked for a solution because it said that there was a better way to have multi-line strings than concatenating them with a '+' at the end of the line.

Always love learning. My ruby-fu is leveling up in small ways. My Vim-fu is as well.

Share this post