Skip to content

Instantly share code, notes, and snippets.

@rayfix
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rayfix/8a037cf8fa9ebbcbfb86 to your computer and use it in GitHub Desktop.
Save rayfix/8a037cf8fa9ebbcbfb86 to your computer and use it in GitHub Desktop.
struct TaggedThing<Tag, Thing> {
var value: Thing
}
protocol A {} // Phantom Type
protocol B {} // Phantom Type
var a = TaggedThing<A, Int>(value: 1)
var b = TaggedThing<B, Int>(value: 2)
a.value // 1
b.value // 2
// a = b compilation error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment