12
12

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.

Swift で空の Array の生成方法色々

Posted at

Apple お勧めのやつ

Apple お勧めの一番ベーシックなのがこれ。

Sample1

var hogeArray: Hoge[] = []

ジェネリクスを使ったアレ

ジェネリクスを使って多少やぼったく書くならこれ。

Sample2

var hogeArray: Array<Hoge> = []

The Swift Programming Language でよく出てくるアレ

初期値を設定しない場合の Array の生成方法として紹介されています。
インスタンス変数として空の Array を生成する時なんかはコレが良いかもしれません。

Sample3

var hogeArray = Hoge[]()

12
12
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
12
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?