I have the following code. How can I resolve the error in the last line?
protocol Animal {
func walk()
}
struct Cat: Animal {
func walk() {}
init() { }
}
var obj: Any = Cat()
var cat = obj as Animal // ERROR: cannot downcast from Any to unrelated type Animal
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…