Avatar
protocol Foo { static var value: String { get } } extension Foo { static var value: String { return "real" } } extension Foo { static func printValue(_ value: String = Self.value) { print(value) } } struct FooImpl: Foo { } FooImpl.printValue() // "real" protocol Test { } extension Foo where Self: Test { static var value: String { return "test" } } struct FooTest: Foo, Test { } FooTest.printValue() // "test"
8:03 AM
↑実験用コード