Skip to content

Instantly share code, notes, and snippets.

@boominadhaprakash
Created December 11, 2017 18:01
Show Gist options
  • Save boominadhaprakash/3e425321bb690b2eaf25c4ed65dd79fa to your computer and use it in GitHub Desktop.
Save boominadhaprakash/3e425321bb690b2eaf25c4ed65dd79fa to your computer and use it in GitHub Desktop.
Removing duplicates from the ArrayofObjects using Higher Order functions
let arrayOfDict:[[String:String]] = [["name":"a"],["name":"b"],["name":"a"]]
var filteredDict = [[String:String]]()
var filteredName = [String]()
arrayOfDict.map{dict in
if !(filteredName.contains(dict["name"]!)) {
filteredDict.append(dict)
filteredName.append(dict["name"]!)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment