Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

String#size

size

Alias of #length

Returns the count of characters (not bytes) in self:

Example
"\x80\u3042".length # => 2
"hello".length # => 5

String#size is an alias for String#length.

Related: String#bytesize.

See also #length #shellsplit #slice #shellescape also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1