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 配列

Posted at

配列とは

1つの変数で複数の値を持つことができる値。
配列の中には、複数の値を入れることができ、順番で値を管理します。

配列の宣言

変数 = []


fruits = ["りんご", "みかん", "いちご"]
puts fruits
# ターミナル出力
りんご
みかん
いちご

fruitsという変数に、バナナという要素を追加してみます。
fruits = ["りんご", "みかん", "いちご"]
fruits << "バナナ"
puts fruits
# ターミナル出力
りんご
みかん
いちご
バナナ

このように、配列演算子<<を使って配列に要素を追加することができます。

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?