我想知道是否有可能实现这样的事情。
我有这样一个游乐场:从常规方法调用协议默认实现
protocol Foo {
func testPrint()
}
extension Foo {
func testPrint() {
print("Protocol extension call")
}
}
struct Bar: Foo {
func testPrint() {
// Calling self or super go call default implementation
self.testPrint()
print("Call from struct")
}
}
let sth = Bar()
sth.testPrint()
我可以提供一个默认实现extension
但如果Bar
需要的一切,是在默认的实现以及附加的东西呢?
它在某种程度上类似于调用super.
方法在class
es满足实施每个属性等的要求,但我认为没有可能实现与structs
相同。
我会用'Foo.testPrint(个体经营)()' - 问题是,它未能由于分割故障(在7.0 GM和7.1 beta上测试) – Antonio
这是一个奇怪的构造你已经提出 – cojoj
每个实例方法是一个静态的curried方法,以一个实例作为其第一个参数 – Antonio