Skip to content

Instantly share code, notes, and snippets.

@matiasdim
Created December 4, 2020 18:11
Show Gist options
  • Save matiasdim/64b52722b265a737dfd0cb6fc17c55a3 to your computer and use it in GitHub Desktop.
Save matiasdim/64b52722b265a737dfd0cb6fc17c55a3 to your computer and use it in GitHub Desktop.
class Rectangle {
var width: Double
var height: Double
init(width: Double, height: Double) {
self.width = width
self.height = height
}
func area() -> Double {
return width * height
}
}
class Square: Rectangle {
// Some extra methods that Rectangle does not implement
}
let square = Square(width: 2, height: 3) // Is that an actual square?
let squareArea = square.area()
print(squareArea)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment