I have the following code. How can I resolve the error in the last line?
protocol Animal {
func walk()
}
struct Cat: Animal {
func walk() {}
in
As far as I have been able to observe, AnyObject can only be downcast to an instances of class types(†) and Any can only be downcast to types (class or otherwise), it is not possible to cast them to a protocol.
I don't know if I would qualify this as a bug or not, if this holds then perhaps it was implemented this way for a good reason - but @Bryan's workaround (casting to a type first and then to a protocol) at least "resolves the error"!
(†) notable exceptions include being able to downcast from AnyObject to the core data types Int, String, etc.