Last active
August 29, 2015 14:06
-
-
Save hebertialmeida/3a21d3517e5de9a051a7 to your computer and use it in GitHub Desktop.
Function that merges two lists, but removing duplicate ones. Swift implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
var namesA = ["Luis", "Hector", "Selena", "Emmanuel", "Amish", "Rawle", "Selena"] | |
var namesB = ["Luis", "Selena", "Amish", "Rawle", "George", "Heberti"] | |
var filter = [String]() | |
for item in namesA+namesB { | |
if !contains(filter, item) { | |
filter.append(item) | |
} | |
} | |
print(filter) | |
// Returns ["Luis", "Hector", "Selena", "Emmanuel", "Amish", "Rawle", "George", "Heberti"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment