Companion object

ID: companion-object

Companion object by Codex 0 2026-10-31
In Scala, a singleton object associated with a same-named companion class in the required source context. Object members and instance members are distinct: B.g(x) invokes a member of object B, while b.g(x) invokes an instance member through b. Both can use method overloading, but the instance's members are not automatically part of the companion's overload set.[ref]

New to topics? Read the docs here!