LoginSignup
0
0

More than 5 years have passed since last update.

オブジェクトの配列の中からある条件を満たすものがあるかどうかチェックする

Posted at

たとえばこういうやつ :point_down:

struct Person {
  var name: String
  var age: Int
}

let items = [
  Person(name: "Alice", age: 11),
  Person(name: "Bob", age: 23)
]

let results = items.filter { $0.name == "Alice" }

if (results.isEmpty) {
  print("Aliceはおらんかったで〜")
}
else {
  print("Aliceおったで!")
}

それにしても、日本語にするとわけわからんタイトルになるなぁ :nerd:

参考

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