1
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.

タカシAdvent Calendar 2022

Day 14

【Swift】配列の要素の数を取得する

Posted at

count

配列の要素の数を取得するにはcountを使用する。

var characters: [String] = ["ロイド", "ヨル", "アーニャ", "ボンド", "ダミアン"]
print(characters.count) // 5

isEmpty

配列の要素が空(nil)かどうかを判定するにはisEmptyを使用する。

var characters: [String] = ["ロイド", "ヨル", "アーニャ", "ボンド", "ダミアン"]
print(characters.isEmpty) // false

ちなみにこの記事の投稿日は12/25です。

let myGirlfriend: [String] = []
print(myGirlfriend.isEmpty) // true

メリークリスマス。

1
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
1
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?