Created
December 6, 2014 00:10
-
-
Save drodriguez/64c470cf59eae85767b1 to your computer and use it in GitHub Desktop.
Computed variable to return type conforming protocol.
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
protocol TestProtocol { | |
} | |
class TestClass : TestProtocol { | |
} | |
class TestClass2 { | |
} | |
struct Test { | |
var a: TestClass.Type { | |
get { | |
return TestClass.self | |
} | |
} | |
var b: TestProtocol.Type { | |
get { | |
return TestClass.self | |
} | |
} | |
var c: TestProtocol.Type { | |
get { | |
return TestClass2.self // Type 'TestClass2' does not conform to protocol 'TestProtocol' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment