Avatar
お!これ治るんですね
1:07 AM
1:09 AM
@swift-main -swift-version 5 protocol Animal {} extension Animal { init(_animal: Self) { self = _animal } } class AnimalBase: Animal { convenience init(with animal: AnimalBase) { self.init(_animal: animal) } } class Cat: AnimalBase { let _name = "Tama" var name: String { return _name } func bark() { print(name) } } class Dog: AnimalBase {} let animal = Cat(with: Dog()) animal.bark()