Ruby | String + Method
Last Updated :
07 Jan, 2020
+() 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:
puts "Hello " + "Geeks!"
puts "Ruby " + "String"
|
Output:
Hello Geeks!
Ruby String
Example 2:
puts "Hey " + "Champ"
puts "Kirti " + "Mangal"
|
Output:
Hey Champ
Kirti Mangal
Share your thoughts in the comments
Please Login to comment...