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

いつも忘れてしまう「配列の末尾に追加するメソッド」を言語ごとにまとめてみた

Last updated at Posted at 2021-07-28

いくつかの言語を同時並行で触っていると、「配列の末尾に追加するメソッド」が分からん!自分はなんて初心者なんだ、と嘆くことが多々ある。

pushなの?
appendなの?
putなの?
はたまたそれ以外?
そんなことに悩む時間を少しでも減らせるように、こんな記事を書いてみた。

Java

List<Integer> list = new ArrayList<Integer>();
list.add(item);

JavaScript

list.push(item)

Python

list.append(item)

PHP

array_push(list, item1, item2...)

Ruby

list.push(item)

Go

※Goでは可変長の配列はSliceという型

append(slice, item)
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?