Ruby | String casecmp? Method Last Updated : 08 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Returns: This method will returns the numbers based on the equality of the str and other_str. It can also return nil if the two strings have incompatible encodings, or if other_str is not a string. Example 1: Ruby # Ruby program to demonstrate # the casecmp? method # Taking a string and # using the method puts "RuBy".casecmp?("ruby") puts "GeeksforGeeks".casecmp?("gfg") Output: true false Example 2: Ruby # Ruby program to demonstrate # the casecmp? method # Taking a string and # using the method # here it will give nil puts "\u{e5 f6 dc}".encode("ISO-8859-1").casecmp?("\u{c4 d4 de}") puts "GFG".casecmp?("250") Output: false Comment More infoAdvertise with us Next Article Ruby | String chomp! Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads 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 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 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 empty? Method 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 demon 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 Like