Skip to content

Instantly share code, notes, and snippets.

@vvviiimmm
Last active February 19, 2017 19:28
Show Gist options
  • Select an option

  • Save vvviiimmm/02be9c719c4e85e52a59955acbb2bb7e to your computer and use it in GitHub Desktop.

Select an option

Save vvviiimmm/02be9c719c4e85e52a59955acbb2bb7e to your computer and use it in GitHub Desktop.
// Won't compile
trait Shape {
// vvv (hmm)
def area(???): Double
}
case class Circle(radius: Double)
case class Rectangle(width: Double, length: Double)
class CircleShape extends Shape {
override def area(circle: Circle) : Double = math.Pi * math.pow(circle.radius, 2)
}
class RectangleShape extends Shape {
override def area(rectangle: Rectangle): Double = rectangle.width * rectangle.length
}
// vvv (but what about this?)
def areaOf(shape: Shape): Double = shape.area(???)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment