Skip to content

Instantly share code, notes, and snippets.

@adambyram
Created August 5, 2015 18:27
Show Gist options
  • Save adambyram/e9ad9f0a9b04cda23c3c to your computer and use it in GitHub Desktop.
Save adambyram/e9ad9f0a9b04cda23c3c to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
class Account: Hashable {
var accountID: String = ""
var hashValue: Int = 0
}
func ==(lhs: Account, rhs: Account) -> Bool {
return lhs.accountID == rhs.accountID
}
class FooAccount: Account {
}
class BarAccount: Account {
}
let foo = FooAccount()
foo.accountID = "foo"
foo.hashValue = 1
let bar = BarAccount()
bar.accountID = "bar"
bar.hashValue = 2
var accounts = Set<Account>()
accounts.insert(foo)
accounts.insert(bar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment