Skip to content

Instantly share code, notes, and snippets.

@niwatako
Created May 14, 2016 05:26
Show Gist options
  • Save niwatako/74154a10b8f2ba8ba41364e4807d3a67 to your computer and use it in GitHub Desktop.
Save niwatako/74154a10b8f2ba8ba41364e4807d3a67 to your computer and use it in GitHub Desktop.
条件を指定した protocol 継承手段はあるのか #CodePiece
protocol ProtocolA {}
class A<T> {}
class B {}
class C {}
extension A: ProtocolA where T: ClassB {} // extension of type 'A' with constraints cannot have an inheritance clause
assert(A<B>() is ProtocolA)
assert(!(A<C>() is ProtocolA))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment