Scala Wonderland: Semicolons, Singletons and Companion Objects | Javalobby
When a singleton has the same name as a class, it's called to be a companion object of that class. The class is denoted as the companion class. They both must be implemented in the same file. The beauty is that they can access each other's private members. Typical usage is to have factory and helper methods in the companion object.
Read full article from Scala Wonderland: Semicolons, Singletons and Companion Objects | Javalobby
No comments:
Post a Comment