Ruby | String chr Method Last Updated : 13 Dec, 2019 Comments Improve Suggest changes Like Article Like Report 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 # Ruby program to demonstrate # the chr method # Taking a string and # using the method puts "Ruby".chr puts "Method".chr Output: R M Example 2: Ruby # Ruby program to demonstrate # the chr method # Taking a string and # using the method puts "String".chr puts "Class".chr Output: S C Comment More infoAdvertise with us Next Article Ruby | String chr Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads Ruby | String chars() Method chars is a String class method in Ruby which is used to return an array of characters in str. Syntax: str.chars Parameters: Here, str is the given string Returns: An array of the characters. Example 1: Ruby # Ruby program to demonstrate # the chars method # Taking a string and # using the method put 1 min read Ruby | String chop! Method chop! is a String class method in Ruby which is used to return a new String with the last character removed. Both characters are removed if the string ends with \r\n, b. It will return nil if the string is empty. Syntax:str.chop!Parameters: Here, str is the given string.Returns: A new string having 1 min read Ruby | String chop Method chop is a String class method in Ruby which is used to return a new String with the last character removed. Both characters are removed if the string ends with \r\n, b. Applying chop to an empty string returns an empty string. Syntax:str.chopParameters: Here, str is the given string.Returns: A new 1 min read Ruby | String crypt Method crypt is a String class method in Ruby which is used to returns the string generated by calling crypt(3) standard library function with str and salt_str. Syntax: crypt(salt_str)-> new_str Parameters: Here, str is the given string and salt_str is the specified salt for crypt method. Example 1: Rub 1 min read Ruby | String chomp! Method chomp! is a String class method in Ruby which is used to returns new String with the given record separator removed from the end of str (if present). chomp method will also removes carriage return characters (that is it will remove \n, \r, and \r\n) if $/ has not been changed from the default Ruby r 1 min read Ruby | String chomp Method chomp is a String class method in Ruby which is used to returns new String with the given record separator removed from the end of str (if present). chomp method will also remove carriage return characters (that is it will remove \n, \r, and \r\n) if $/ has not been changed from the default Ruby rec 1 min read Ruby | String hex Method hex is a String class method in Ruby which is used to treats the leading characters from the given string as a string of hexadecimal digits (with an optional sign and an optional 0x) and returns the corresponding number. Zero is returned on error. Syntax: str.hex Parameters: Here, str is the given s 1 min read Ruby| String Clear Method clear is a String class method in Ruby which is used to make the string empty. Syntax: str.clear Parameters: Here, str is the given string. Return : An empty string. Example 1: Ruby # Ruby program to demonstrate # the clear method # Taking a string and # using the method puts "String".clea 1 min read Ruby | String * Method String# * is a String class method in Ruby which is used to returns a new String containing integer copies of the receiver. Here, integer must be greater than or equal to 0. Syntax: str * Integer Parameters: Here, str is the required string and integer is the number of copies. Returns: This method r 1 min read Ruby | String + Method +() 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. Exa 1 min read Like