Avatar
@swift-4.2.4 @swift-5.0.3 class Parent { var id: Int init(id: Int) { self.id = id } } protocol Abstract where Self: Parent { var name: String { get } } extension Abstract { func printProfile() { print("\(id) \(name)") } } class Child: Parent, Abstract { var name: String init(id: Int, name: String) { self.name = name super.init(id: id) } } let c = Child(id: 42, name: "hoge") c.printProfile()