Ruby 2.6.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Stringクラス > length
length -> Integer
[permalink][rdoc]size -> Integer
文字列の文字数を返します。バイト数を知りたいときは bytesize メソッドを使ってください。
"test".length # => 4
"test".size # => 4
"テスト".length # => 3
"テスト".size # => 3
"\x80\u3042".length # => 2
"\x80\u3042".size # => 2
[SEE_ALSO] String#bytesize