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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s