Skip to content

Instantly share code, notes, and snippets.

@mikekavouras
Last active April 11, 2016 20:03
Show Gist options
  • Select an option

  • Save mikekavouras/ba741be6eb8562c8093ac9d8f4dc31a7 to your computer and use it in GitHub Desktop.

Select an option

Save mikekavouras/ba741be6eb8562c8093ac9d8f4dc31a7 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
struct Obj {
let id: String
init(id: String) {
self.id = id
}
}
extension Obj: Equatable {}
func ==(lhs: Obj, rhs: Obj) -> Bool {
return lhs.id == rhs.id
}
let one = Obj(id: "beep")
let two = Obj(id: "beep")
let three = Obj(id: "boop")
var arr = [one, two, three]
var uniq = [Obj]()
for item in arr {
guard uniq.indexOf(item) == nil else {
continue
}
uniq.append(item)
}
print(uniq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment