Ruby Language Strings String concatenation

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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"


Got any Ruby Language Question?