Skip to content

Instantly share code, notes, and snippets.

@xcadaverx
Created July 7, 2018 19:02
Show Gist options
  • Save xcadaverx/48f0a8c5d8c5b1b7c5a978b29d970046 to your computer and use it in GitHub Desktop.
Save xcadaverx/48f0a8c5d8c5b1b7c5a978b29d970046 to your computer and use it in GitHub Desktop.
class FooSubClass: SomeFoo {}
extension Foo where Self: FooSubClass {
func bar() {
print("Foo.FooSubclass.bar()")
}
}
let fooSubClassOne: Foo = FooSubClass()
fooSubClassOne.bar() // Foo.SomeFoo.bar() 🤨
let fooSubClassTwo: SomeFoo = FooSubClass()
fooSubClassTwo.bar() // Foo.SomeFoo.bar() 🧐
let fooSubClassThree: FooSubClass = FooSubclass()
fooSubClassThree.bar() // Foo.FooSubClass.bar() 🤯
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment