Skip to content

Instantly share code, notes, and snippets.

@ostretsov
Last active August 29, 2015 14:13
Show Gist options
  • Save ostretsov/989c64f468c827f8ed92 to your computer and use it in GitHub Desktop.
Save ostretsov/989c64f468c827f8ed92 to your computer and use it in GitHub Desktop.
class Rectangle(width: Int, height: Int) {
def getWidth: Int = width
def getHeight: Int = height
}
class Square(side: Int) extends Rectangle(side, side) {
def getSomething: Int = 1
}
def area(rectangle: Rectangle): Int = {
rectangle.getHeight * rectangle.getWidth * rectangle.getSomething // it would't work!
}
val s = new Square(5)
println(area(s))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment