protocol Heightable {
var height: Double { get }
}
class Base: Heightable {
var height = 21.0
// ...
}
class Sub: Base {
override init() {
super.init()
height = 22.0
}
}
let arr: [Heightable] = [Base(), Sub() , Sub()]
arr.forEach { print($0.height) } // 21.0 22.0 22.0