I want to have a property in BaseClass which is an array of type anything which extends Movable and in subclass I want to override the same property with type Transportable which extends Movable.
How do we declare "anything which extends Movable" in Swift?
protocol Movable{
func move()
}
struct Transportable : Movable{
func transport()
}
class BaseClass{
var myProperty: [Movable] = []
}
class MyClass: BaseClass{
override var myProperty = [Transportable]()
}
It doesn't compile and gives me an error:
Property 'myProperty' with type '[Transportable]' cannot override a property with type '[Movable]'