Ruby | String length Method Last Updated : 08 Jan, 2020 Comments Improve Suggest changes Like Article Like Report length is a String class method in Ruby which is used to find the character length of the given string. Syntax: str.length Parameters: Here, str is the string whose length is to be calculated Returns:It will return the character length of the str. Example 1: Ruby # Ruby program to demonstrate # the length method # Taking a string and # using the method puts "GFG".length puts "geeksforgeeks".length Output: 3 13 Example 2: Ruby # Ruby program to demonstrate # the length method # Taking a string and # using the method puts "g4g".length puts "ruby string".length Output: 3 11 Comment More infoAdvertise with us Next Article Ruby | String length Method K Kirti_Mangal Follow Improve Article Tags : Ruby Ruby-Methods Ruby String-class Similar Reads 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 delete() Method delete is a String class method in Ruby which is used to return a copy of the given string with all characters in the intersection of its arguments deleted. Syntax: str.delete(parameter_list) Parameters: Here, str is the given string and parameter_list are the specified characters. Returns: A new co 1 min read Ruby | String delete! Method delete! is a String class method in Ruby which is used to perform a delete operation, returning the given string, or nil if the given string was not modified. Syntax: str.delete!(parameter_list) Parameters: Here, str is the given string and parameter_list are the specified characters. Returns: nil i 1 min read Ruby | String count() Method count is a String class method in Ruby. In this method each parameter defines a set of characters to which is to be counted. The intersection of these sets defines the characters to count in the given string. Any other string which starts with a caret ^ is negated. Syntax:str.count(parameter_list) P 1 min read Ruby | String <=> Method <=>() is a String class method in Ruby which is used for comparisons of the strings. This method returns -1, 0, +1, or nil depending on whether the specified string is less than, equal to, or greater than other_string. Syntax: str other_string Parameters: Here, str and other_string are the str 1 min read Like