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 5 years have passed since last update.

配列〜Udemy〜

0
Posted at

配列

配列って。。。

・複数の要素を持つ変数。

・Arrayクラスのオブジェクト。

・配列の要素もオブジェクト。

・配列名[要素番号]

配列の生成のしかた

・[“beef”,”pork”,”chicken”]

・%w(beef pork chicken) ➡️%W・・・配列名に、当てはめていくやり方例えば、
 flowers = %w(lib rose tulip)とすると、、[“lily”,”rose”,”tulip”]となる

・データの追加・・・・・配列名<<加えたい値

番号で代入もできる

flowers[3] = “tsubaki”           3を椿とする
>>”tsubaki”
puts flowers
Lily
Rose
Tulip
tsubaki

配列を確かめる動き

オブジェクト.empty?・・・配列は空ですか?
返り値・・・nil
false
true


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?