Removing objects from an array based on another array

前端 未结 9 1455
南方客
南方客 2021-02-05 01:14

I have two arrays like this:

var arrayA = [\"Mike\", \"James\", \"Stacey\", \"Steve\"]
var arrayB = [\"Steve\", \"Gemma\", \"James\", \"Lucy\"]

9条回答
  •  一向
    一向 (楼主)
    2021-02-05 01:26

    @francesco-vadicamo's answer in Swift 2/3/4+

     arrayA = arrayA.filter { !arrayB.contains($0) }
    

提交回复
热议问题