Skip to content

Instantly share code, notes, and snippets.

@stigi
Created December 6, 2015 07:16
Show Gist options
  • Save stigi/c5c449a701d75cc86911 to your computer and use it in GitHub Desktop.
Save stigi/c5c449a701d75cc86911 to your computer and use it in GitHub Desktop.
protocol MyProtocol {
static func staticHello()->()
func hello()->()
}
// default implementation
extension MyProtocol {
static func staticHello()->() {
print("static bello")
}
func hello()->() {
// staticHello() // How can I call staticHello() from here?
}
}
struct MyStruct: MyProtocol {
}
MyStruct().hello()
MyStruct.staticHello()
@AlexanderNey
Copy link

Self.staticHello()
// with greetings from London ;)

@stigi
Copy link
Author

stigi commented Dec 6, 2015

@AlexanderNey thx! this or self.dynamicType.staticHello() work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment