Skip to content

Instantly share code, notes, and snippets.

@motokiee
Created November 14, 2015 05:49
Show Gist options
  • Save motokiee/3dc68a488ffcf2e44c93 to your computer and use it in GitHub Desktop.
Save motokiee/3dc68a488ffcf2e44c93 to your computer and use it in GitHub Desktop.
extensionで新しく定義の追加できるの知らなかった。protocolに定義したもののデフォルト値を設定するだけじゃなかったのか。 #cswift #CodePiece
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