0
0

More than 1 year has passed since last update.

配列の先頭、末尾に追加する

Posted at

配列の最初に追加する

配列.unshift(その配列の先頭に追加する要素)

irb(main):022:0> a = []
=> []
irb(main):023:0> a.unshift("a","b")
=> ["a", "b"]
irb(main):024:0> a.unshift("c","d")
=> ["c", "d", "a", "b"]

出典 https://techacademy.jp/magazine/20565

配列の最後尾に追加する

配列.push(その配列の末尾に追加する要素)

irb(main):025:0> a.push("e","f")
=> ["c", "d", "a", "b", "e", "f"]

出典 https://techacademy.jp/magazine/20565

気づき

これ使おう。

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