Last active
March 30, 2019 06:52
-
-
Save yimajo/16d1e1ce199dda4694b605b584bbe609 to your computer and use it in GitHub Desktop.
Swift5からprotocolでclassをinheritできるようになった?
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
class Hoge {} | |
// Swift 5から | |
protocol ComponentA: Hoge { | |
func name() -> String | |
} | |
// Swift 4でも同じようなことはできた | |
protocol ComponentB where Self: Hoge { | |
func name() -> String | |
} | |
class Piyo: Hoge, ComponentA, /*ComponentB*/ { | |
func name() -> String { | |
return "piyo" | |
} | |
} | |
print(Piyo().name()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment