Ruby Language String concatenation


Example

Concatenate strings with the + operator:

s1 = "Hello"
s2 = " "
s3 = "World"

puts s1 + s2 + s3
# => Hello World

s = s1 + s2 + s3
puts s
# => Hello World

Or with the << operator:

s = 'Hello'
s << ' '
s << 'World'
puts s
# => Hello World

Note that the << operator modifies the object on the left hand side.

You also can multiply strings, e.g.

"wow" * 3
# => "wowwowwow"