Avatar
swiftbot BOT 8/2/2018 7:22 AM
Author icon
rintaro
protocol AnimalProtocol {} extension AnimalProtocol { mutating func replace(with obj: Self) { self = obj } } class AnimalBase : AnimalProtocol {} class Cat: AnimalBase {} class Dog: AnimalBase {} var cat: AnimalBase = Cat() cat.replace(with: Dog()) print(type(of: cat))
Version:
swift-4.1.1-RELEASE
Output:
Dog
Error: