Ruby | String + Method
Last Updated :
07 Jan, 2020
Improve
+() 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.
Ruby
Output:
Ruby
Output:
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"
Hello Geeks! Ruby StringExample 2:
#ruby 2.3.1
# Ruby program to demonstrate
# the + method
# Taking a string and
# using the method
puts "Hey " + "Champ"
puts "Kirti " + "Mangal"
Hey Champ Kirti Mangal