Companion object

class SomeClass {
    def printFilename() = {
        println(SomeClass.HiddenFilename)
    }
}

object SomeClass {
    private val HiddenFilename = "/tmp/foo.bar"
}
class Pizza {
}

object Pizza {
}

Is an object that’s declared in the same file as a class, and has the same name as the class.

Companion object — Structure map

Clickable & Draggable!

Companion object — Related pages: