Avatar
omochimetaru 8/2/2018 10:55 AM
@swiftbot protocol Assignable { mutating func assign(from other: Self) } extension Assignable { mutating func assign(from other: Self) { self = other } } class Animal : Assignable { func speak() { fatalError() } } class Cat : Animal { override func speak() { print("にゃー") } } class Dog : Animal { override func speak() { print("わん") } } var cat: Animal = Cat() cat.assign(from: Dog()) cat.speak()
🛠 1