Ruby | String empty? Method Last Updated : 08 Jan, 2020 Comments Improve Suggest changes Like Article Like Report empty? is a String class method in Ruby which is used to check whether the string length is zero or not. Syntax: str.empty? Parameters: Here, str is the given string which is to be checked. Returns: It returns true if str has a length of zero, otherwise false. Example 1: Ruby # Ruby program to demonstrate # the empty? method # Taking a string and # using the method puts "checking".empty? puts "method".empty? Output: false false Example 2: Ruby # Ruby program to demonstrate # the empty? method # Taking a string and # using the method puts "".empty? puts ".".empty? Output: true false Comment More infoAdvertise with us Next Article Ruby | String empty? Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads 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 charact 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 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 getbyte Method getbyte is a String class method in Ruby which is used to return the indexth byte as an integer. Syntax: str.getbyte(index) Parameters: Here, str is the given string. Returns: Indexth byte as an integer. Example 1: Ruby # Ruby program to demonstrate # the getbyte method # Taking a string and # using 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 casecmp Method casecmp is a String class method in Ruby which is Case-insensitive version of String#<=>. For now, case-insensitivity only works on characters A-Z/a-z, not all of the Unicode characters. This method is different from casecmp! method. Syntax: str.casecmp(other_str) Parameters: Here, str is the 1 min read Ruby | String casecmp? Method casecmp? is a String class method in Ruby which is used to return true if both the string are equal after Unicode case folding and false if they are not equal. Syntax: str.casecmp?(other_str) Parameters: Here, str is the given string to be checked and other_str is the string to which str is compared 1 min read Ruby | String eql? Method eql? is a String class method in Ruby which is used to check whether the strings are equal or not if they have the same length and content. Syntax: str.eql?(Other_str) Parameters: Here, str and other_str are the strings. Returns: True or false basis on the equality. Example 1: Ruby # Ruby program to 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 === Method ===() is a String class method in Ruby which is used to check whether str==obj or not. This method is similar to == method of string class. Syntax: str === obj Parameters: Here, str is the given string and obj is the object to be compared. Returns: True or False based on the equality of the two stri 1 min read Like