Skip to content

Instantly share code, notes, and snippets.

@haranicle
Last active February 16, 2016 09:40
Show Gist options
  • Save haranicle/d83fc5dca1ee200a4332 to your computer and use it in GitHub Desktop.
Save haranicle/d83fc5dca1ee200a4332 to your computer and use it in GitHub Desktop.
なぜなのか #CodePiece
protocol P: Hashable {}
func ==(lhs: S, rhs: S) -> Bool { return lhs.name == rhs.name }
struct S: P {
var name = "struct"
var hashValue: Int { get{ return name.hash } }
}
let setS: Set<S> = [S()]
let setP: Set<P> = [S()] // Protocol 'P' can only be used as a generic constraint because it has Self or assosiated type requirements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment