Open In App

Ruby | String + Method

Last Updated : 07 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
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
#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
#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

Next Article

Similar Reads