Ruby:String Length

From Progzoo
Revision as of 06:24, 23 November 2009 by Spoon! (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to 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