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 object str = "Geeks" # using the method str.concat("ForGeeks") # displaying the result puts str |
Output:
GeeksForGeeks
Example 2:
# Ruby program for concat method # taking a string object str = "Geeks" # using the method # but taking integer also inside the method # it will convert it to character str.concat("ForGeeks", 33) # displaying the result puts str |
Output:
GeeksForGeeks!
Recommended Posts:
- Ruby | Array concat() operation
- Ruby | String inspect Method
- Ruby | String hex Method
- Ruby | String include? Method
- Ruby | String delete_suffix! Method
- Ruby | String dump Method
- Ruby | String each_byte Method
- Ruby | String * Method
- Ruby | String + Method
- Ruby | String << Method
- Ruby | String insert Method
- Ruby | String chomp! Method
- Ruby | String chop! Method
- Ruby | String chop Method
- Ruby | String capitalize() Method
- Ruby | String capitalize! Method
- Ruby | String casecmp Method
- Ruby | String casecmp? Method
- Ruby | String length Method
- Ruby | String reverse Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

