I am confused when I first come across the following piece of code.
In the class Element, there are three function definitions.
Why height and width can use contents directly as a variable of Array[String]?
Is it because every function in Scala is an object or some other rule?
I come from C++ world, so the definition really puzzles me.
abstract class Element {
def contents: Array[String]
def height: Int = contents.length
def width: Int = if (height == 0) 0 else contents(0).length
}