Ruby | String chr Method
chr is a String class method in Ruby which is used to return a one-character string at the beginning of the string.
Syntax:str.chr
Parameters: Here, str is the given string.
Returns: A one-character string at the beginning of the string.
Example 1:
# Ruby program to demonstrate # the chr method # Taking a string and # using the method puts "Ruby".chr puts "Method".chr |
chevron_right
filter_none
Output:
R M
Example 2:
# Ruby program to demonstrate # the chr method # Taking a string and # using the method puts "String".chr puts "Class".chr |
chevron_right
filter_none
Output:
S C
Recommended Posts:
- Ruby | String <=> Method
- Ruby | String =~ Method
- Ruby | String eql? Method
- Ruby | String hex Method
- Ruby | String == method
- Ruby | String << Method
- Ruby | String * Method
- Ruby | String === Method
- Ruby | String + Method
- Ruby | String delete! Method
- Ruby | String delete_prefix Method
- Ruby | String delete_suffix Method
- Ruby | String delete_prefix! Method
- Ruby | String each_str Method
- Ruby | String each_codepoint 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.



