Created
August 5, 2015 18:07
-
-
Save brentsimmons/7ec7e3669ff7ad17e446 to your computer and use it in GitHub Desktop.
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
//: Playground - noun: a place where people can play | |
import Cocoa | |
protocol Account: Equatable { | |
var accountID: String {get} | |
} | |
// https://twitter.com/optshiftk/status/628985834801336320 | |
func ==<T: Account>(lhs: T, rhs: T) -> Bool { | |
return lhs.accountID == rhs.accountID | |
} | |
class FooAccount: Account { | |
let accountID = "foo" | |
} | |
class BarAccount: Account { | |
let accountID = "bar" | |
} | |
let foo = FooAccount() | |
let bar = BarAccount() | |
var accounts = [Account]() | |
// Error on line 29: protocol 'Account' can only be used as a generic constraint because it has Self or associated type requirements |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about this?