Ruby | String dump Method
dump is a String class method in Ruby which is used to generate a version of the given string with all non-printing characters replaced by \nnn notation and all special characters escaped.
Syntax: str.dump
Parameters: Here, str is the given string.
Returns: A new string with all non-printing characters replaced by \nnn notation and all special characters escaped.
Example 1:
# Ruby program to demonstrate # the dump method # Taking a string and # using the method str = "ruby \n ''".dump puts str.dump |
Output:
"\"ruby \\n ''\""
Example 2:
# Ruby program to demonstrate # the dump method # Taking a string and # using the method str = "yumy \n\n\n ''".dump puts str.dump |
Output:
"\"yumy \\n\\n\\n ''\""
Recommended Posts:
- Ruby | String hex Method
- Ruby | String == method
- Ruby | String <=> Method
- Ruby | String chr Method
- Ruby | String eql? Method
- Ruby | String << Method
- Ruby | String + Method
- Ruby | String * Method
- Ruby | String === Method
- Ruby | String =~ Method
- Ruby | String casecmp Method
- Ruby | String delete() Method
- Ruby | String crypt Method
- Ruby | String delete! Method
- Ruby | String grapheme_clusters 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.



