Reduction to the base (super) type in Swift
Forums:
class Shape {
var name: String {
return "Shape"
}
}
class Square: Shape {
override var name: String {
return "Square"
}
}
let square = Square()
//implicit method
var shape: Shape = square
//explicit method
shape = square as Shape
let name = shape.name
//name is "Square"
- Log in to post comments