Created
August 20, 2020 14:41
-
-
Save andersio/c146054f7ed595b1f41f83df5c719940 to your computer and use it in GitHub Desktop.
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 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