Ruby | String capitalize! Method Last Updated : 08 Jan, 2020 Comments Improve Suggest changes Like Article Like Report capitalize! is a String class method in Ruby which is used to return a copy of the given string by converting its first character uppercase and the remaining to lowercase. The only difference between capitalize and capitalize! method is that capitalize! method will return nil if no changes are made. Syntax:str.capitalize! Parameters: Here, str is the given string which is to be converted. Returns: Copy of the string with the first character in uppercase and remaining in lowercase. And nil if no changes are made. Example 1: Ruby # Ruby program to demonstrate # the capitalize! method # Taking the string and # using the method puts "ruby".capitalize!() puts "gfg".capitalize!() Output: Ruby Gfg Example 2: Ruby # Ruby program to demonstrate # the capitalize! method # Taking a string # already in uppercase # it will not give any # output puts "Geeksforgeeks".capitalize!() puts "computer".capitalize!() Output: Computer Comment More infoAdvertise with us Next Article Ruby | String crypt Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads Ruby | String capitalize() Method capitalize is a String class method in Ruby which is used to return a copy of the given string by converting its first character uppercase and the remaining to lowercase. Syntax: str.capitalize Parameters: Here, str is the given string which is to be converted. Returns: Copy of the string with the f 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 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 center() method center is a String class method in Ruby which is used to centers the given string in width. If the specified width is greater than the length of the given string, then this method will return a new string of the specified width with the given string centered and padded otherwise it returns only give 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 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 Like