Last active
August 29, 2015 14:24
-
-
Save tarunon/d65f7a5946a2d5ae5208 to your computer and use it in GitHub Desktop.
Accept type A or B<A>
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
import Foundation | |
protocol Type { | |
typealias Value: Type | |
} | |
extension String: Type { | |
typealias Value = String | |
} | |
struct Attribute<T: Type>: Type { | |
typealias Value = T | |
let t: T | |
} | |
func aFution<T1: Type, T2: Type, V: Type where T1.Value == V, T2.Value == V>(t1: T1, t2: T2) { | |
} | |
aFution("a", t2: "b") | |
aFution(Attribute(t: "a"), t2: "b") | |
aFution("a", t2: Attribute(t: "b")) | |
aFution(Attribute(t: "a"), t2: Attribute(t: "b")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment