Ruby | String inspect Method Last Updated : 09 Dec, 2019 Comments Improve Suggest changes Like Article Like Report inspect is a String class method in Ruby which is used to return a printable version of the given string, surrounded by quote marks, with special characters escaped. Syntax: str.inspect Parameters: Returns: Here, str is the given string. Example 1: Ruby # Ruby program to demonstrate # the inspect method # Taking a string and # using the method puts "Sample".inspect puts "Articles".inspect Output: "Sample" "Articles" Example 2: Ruby # Ruby program to demonstrate # the inspect method # Taking a string and # using the method puts "Ru \n y".inspect puts "Ar\b\\bcles".inspect Output: "Ru \n y" "Ar\b\\bcles" Comment More infoAdvertise with us Next Article Ruby | String inspect Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads Ruby | String insert Method insert is a String class method in Ruby which is used to inserts the specified string before the character at the given index, modifying the given one. Negative indices count from the end of the string, and insert after the given character. Syntax: str.insert(index, other_str) Parameters: Here, str 1 min read Ruby | String index Method index is a String class method in Ruby which is used to returns the index of the first occurrence of the given substring or pattern (regexp) in the given string. It specifies the position in the string to begin the search if the second parameter is present. It will return nil if not found. Syntax: s 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 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 Like