Last active
August 29, 2015 14:22
-
-
Save rayfix/8a037cf8fa9ebbcbfb86 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
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