In Scala, instead of using a static method, it has a single-user companion object.
The type of a singleton companion object is different from the companion class, and the type alias is associated with the class, not the single object.
For example, you might have the following code:
class MyClass {
val x = 3;
}
object MyClass {
val y = 10;
}
type C = MyClass
val myClass: C = new MyClass()
val myClassY = MyClass.y
val myClassY2 = C.y
source
share