Skip to content

Instantly share code, notes, and snippets.

@wingyplus
Created January 29, 2017 05:17
Show Gist options
  • Save wingyplus/314e465aae601135efff225da7132989 to your computer and use it in GitHub Desktop.
Save wingyplus/314e465aae601135efff225da7132989 to your computer and use it in GitHub Desktop.
protocol A {
func doSomething() -> String
}
// AbstractA
extension A {
func doSomething() -> String {
return "Hello from AbstractA"
}
}
class B : A {
}
let b = B()
print(b.doSomething())
@olarn
Copy link

olarn commented Jan 29, 2017

protocol A {
func value: String { get }
func letSubClassImplement()
func doSomething() -> String
}

// AbstractA
extension A {
func doSomething() -> String {
return "Hello from AbstractA"
}
}

class B : A {
func value: String {
get {
return "some value"
}
}
func letSubClassImplement() {
// sub class implementation
}
}

let b = B()
print(b.doSomething())

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