Ruby:String Length

From Progzoo
Jump to: navigation, search

Use string.length to get the number of characters.

s                   s.length          

one                 3                   
two                 3                   
three               5                   
four                4                   


[Font] [Default] [Show] [Resize] [History] [Profile]

.length can also be used to get the length of an array

You can also use the method .size It is identical to .length