Uncategorized

Classes and Objects

  • A class and its companion object can access each other’s private members
  • The difference between singleton objects and classes is that singleton objects cannot take parameters and classes can
  • A singleton object which does not share the same name with a companion object is called a standalone object. You can use standalone objects for collecting related utility methods together or defining an entry point to a Scala application
  • To run a Scala application you must supply the name of a standalone singleton object with a main method that takes one parameter, an Array[String], and has a result type of unit:
object Summer{
    def main(args: Array[String]) {
        ???
    }
}
  • A sealed class cannot have any new subclasses added except the ones in the same file