Created
November 14, 2015 05:49
-
-
Save motokiee/3dc68a488ffcf2e44c93 to your computer and use it in GitHub Desktop.
extensionで新しく定義の追加できるの知らなかった。protocolに定義したもののデフォルト値を設定するだけじゃなかったのか。 #cswift #CodePiece
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 Foo { | |
func hoge() -> Void | |
} | |
extension Foo { | |
func hoge() -> Void { | |
print("hoge") | |
} | |
func hoge2() -> Void { | |
print("hoge2") | |
} | |
} | |
struct Some: Foo { | |
} | |
let some = Some() | |
some.hoge1() // hoge | |
some.hoge2() // hoge2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment