Compare value from two struct in swift

后端 未结 4 1570
梦毁少年i
梦毁少年i 2021-01-25 18:09

I have two struct and two arrays corresponding to it and I am trying to compare the two array values and print it in one filtered array i did try and use filter but its giving m

4条回答
  •  悲哀的现实
    2021-01-25 18:50

    If you're looking to filter oneData to only those elements that have a matching ID field in twoData, you want:

    let mainArray = oneData.filter { i in twoData.contains { i.ID == $0.ID } }
    

提交回复
热议问题