0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ruby lengthについて

Posted at

はじめに

※以下の内容には誤りが含まれる可能性があります

lengthとは何か

Rubyで文字列の長さ(文字数)・配列の要素数を調べるために使うメソッドです。

lengthメソッドの使い方

文字列の長さを調べる場合

str = '123456789'
str.length
#=> 9

配列の長さを調べる場合

data = [1,2,3,4,5,6,7,8,9]
data.length
#=> 9

まとめ

lengthとは長さのことです。Rubyでlengthは文字列の長さ、配列の長さを調べるためのメソッドです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?