0
2

はじめに

配列から特定の要素を削除したい時に見る用記事

実装

基本はこっちを使う

array.removeAll { $0.id == "001" }
return array

エラー

Cannot use mutating member on immutable value: 'xxx' is an immutable capture

このようなエラーが出る場合はこっちを使う

let newArray = array.filter { $0.id != "001" }
return newArray

参考記事

0
2
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
2