Not IN keyword In swift

Is there a not in keyword in swift similar to what's found in python ?
Screen Shot 2021-11-23 at 1.47.44 PM

if !noduplist.contains(element) {
  ...
}

And you probably want noduplist to be a Set rather than an Array.

However, for the specific algorithm you describe, it may be preferable to use removeAll(where:), as in:

extension RangeReplaceableCollection where Element: Hashable {
  mutating func removeDuplicates() {
    var alreadySeen: Set<Element> = []
    removeAll { !alreadySeen.insert($0).inserted }
  }
}
Terms of Service

Privacy Policy

Cookie Policy