Scala - Main (Top-Level Objects)

About

In Scala, the main or entry point method is defined in an object.

An object can be made executable by either:

Two way

App

object extends the type App trait

object HelloWorld extends App {
  println("Hello, World!")
}

If that object extends trait App, then all statements contained in that object will be executed. otherwise you have to add a method main which will act as the entry point of your program.

Main

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello, World!")
  }
}

Powered by ComboStrap