Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Ruby | String length Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 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 program to demonstrate
# the length method
   
# Taking a string and
# using the method
puts "g4g".length
puts "ruby string".length


Output:

3
11
My Personal Notes arrow_drop_up
Last Updated : 08 Jan, 2020
Like Article
Save Article
Similar Reads