Effective Scala, part 7 - entry point of a project

Posted on in

While a scala worksheet are evaluated from top to bottom, a scala project needs an entry point.

Only two requirements:

  • It needs to be a top-level method or an object-level method, but not a class-level method
  • It needs to be annotated with @main

Otherwise

  • It can be named anything.
  • It can be put in an arbitrary source file.

A source file in a project cannot contain top-level statements (e.g., println), only top-level definitions (def, val, var, trait, object, class definitions) .

Post author's photo Written by Jayesh Bhoot