Skip to content

Instantly share code, notes, and snippets.

@andersio
Created August 20, 2020 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersio/c146054f7ed595b1f41f83df5c719940 to your computer and use it in GitHub Desktop.
Save andersio/c146054f7ed595b1f41f83df5c719940 to your computer and use it in GitHub Desktop.
protocol P {
func foo()
func bar()
}
extension P {
func foo() { print("foo() from P") }
func bar() { print("bar() from P") }
}
class Base: P {
func foo() {
print("foo() from Base")
}
//func bar() { print("bar() from Base") }
}
class Refined: Base {
override func foo() {
print("foo() from Refined")
}
//override
func bar() {
print("bar() from Refined")
}
}
let a = Refined()
a.foo()
(a as P).foo()
a.bar()
(a as P).bar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment