Reputation: 746
Is there an equivalent to PHP's strlen
method in Ruby?
I know about Ruby's String#count
method, but it requires that I define a set of characters to count. In my situation, I want to count ALL characters, not just certain characters.
Upvotes: 11
Views: 22999
Reputation: 118261
Use String#size
or String#length
method. It will work for you.
Returns the character length of
str.
Example :
"abc 12-".size # => 7
Upvotes: 21