I have a compile error and I do not understand it.
case class Point(x: Int, y: Int)
trait Rectangular {
def topLeft: Point
def bottomRight: Point
def left = topLeft().x //Compile error occurring here
def right = bottomRight.x
def width = right - left
// any many more concrete geometric methods.
}
I am getting a compile error on the line where the third method is defined, saying "Point does not take parameters".
But I thought that you can invoke a function that does not take parameters with or without the ()
. As topLeft
is just a method that has no parameters and has a return type of Point
.