Open In App

Ruby | String + Method

Last Updated : 07 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

+() is a String class method in Ruby which is used to return a new string that contains the other specified string concatenated to the given string.

Syntax: str + other_str

Parameters: Here, str and other_str are the strings which are to be concatenated.

Returns: Returns the concatenated string.

Example 1:




#ruby 2.3.1 
     
# Ruby program to demonstrate
# the + method
     
# Taking a string and
# using the method
puts "Hello " + "Geeks!"
puts "Ruby " + "String"


Output:

Hello Geeks!
Ruby String

Example 2:




#ruby 2.3.1 
     
# Ruby program to demonstrate
# the + method
     
# Taking a string and
# using the method
puts "Hey " + "Champ"
puts "Kirti " + "Mangal"


Output:

Hey Champ
Kirti Mangal

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads