Created
December 31, 2019 02:43
-
-
Save greenchiu/19c4278dc65c30306148af34b7478d21 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 X { | |
func hello() | |
} | |
extension X { | |
func hello() { | |
print("Hello") | |
} | |
} | |
extension X where Self: A { | |
func hello() { | |
print("是在 Hello?") | |
} | |
} | |
extension X where Self: B { | |
func hello() { | |
print("是在 Hello 2?") | |
} | |
} | |
class A: X {} | |
class B: A {} | |
A().hello() | |
let b: X = B() | |
b.hello() | |
//是在 Hello? | |
//是在 Hello? | |
let c = B() | |
c.hello() | |
//是在 Hello 2? |
@ytyubox 中招當下會反應不過來,踩過就知道了 orz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
看了覺得神奇! 以後寫

extension
要小心了