Ruby | String concat Method
concat is a String class method in Ruby which is used to Concatenates two objects of String. If the given object is an Integer, then it is considered a codepoint and converted to a character before concatenation.
Syntax:String_Object.concat(String_Object)
Parameters: This method can take the string object and normal string as the parameters. If it will take integer then this method will convert them into the character.
Returns: This method returns the concatenated string as a result.
Example 1:
# Ruby program for concat method # taking a string objectstr = "Geeks" # using the methodstr.concat("ForGeeks") # displaying the resultputs str |
Output:
GeeksForGeeks
Example 2:
# Ruby program for concat method # taking a string objectstr = "Geeks" # using the method# but taking integer also inside the method# it will convert it to characterstr.concat("ForGeeks", 33) # displaying the resultputs str |
Output:
GeeksForGeeks!


