scala

App

trait App extends DelayedInit

The App trait can be used to quickly turn objects into executable programs. Here is an example:

object Main extends App {
Console.println("Hello World: " + (args mkString ", "))
}

Here, object Main inherits the main method of App.

args returns the current command line arguments as an array.

Caveats

It should be noted that this trait is implemented using the DelayedInit functionality, which means that fields of the object will not have been initialized before the main method has been executed.

It should also be noted that the main method will not normally need to be overridden: the purpose is to turn the whole class body into the “main method”. You should only chose to override it if you know what you are doing.

Source
App.scala
Version

2.1, 15/02/2011

Linear Supertypes
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. App
  2. DelayedInit
  3. AnyRef
  4. Any
Implicitly
  1. by StringAdd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from App to StringAdd[App] performed by method StringAdd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (App, B)

    Implicit information
    This member is added by an implicit conversion from App to ArrowAssoc[App] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. def args: Array[String]

    The command line arguments passed to the application's main method.

    The command line arguments passed to the application's main method.

    Attributes
    protected
  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def delayedInit(body: ⇒ Unit): Unit

    The init hook.

    The init hook. This saves all initialization code for execution within main. This method is normally never called directly from user code. Instead it is called as compiler-generated code for those classes and objects (but not traits) that inherit from the DelayedInit trait and that do not themselves define a delayedInit method.

    body

    the initialization code to be stored for later execution

    Definition Classes
    AppDelayedInit
  12. def ensuring(cond: (App) ⇒ Boolean, msg: ⇒ Any): App

    Implicit information
    This member is added by an implicit conversion from App to Ensuring[App] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. def ensuring(cond: (App) ⇒ Boolean): App

    Implicit information
    This member is added by an implicit conversion from App to Ensuring[App] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  14. def ensuring(cond: Boolean, msg: ⇒ Any): App

    Implicit information
    This member is added by an implicit conversion from App to Ensuring[App] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: Boolean): App

    Implicit information
    This member is added by an implicit conversion from App to Ensuring[App] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  18. val executionStart: Long

    The time when the execution of this program started, in milliseconds since 1 January 1970 UTC.

  19. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  20. def formatted(fmtstr: String): String

    Returns string formatted according to given format string.

    Returns string formatted according to given format string. Format strings are as for String.format (@see java.lang.String.format).

    Implicit information
    This member is added by an implicit conversion from App to StringFormat[App] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  21. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  22. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  23. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  24. def main(args: Array[String]): Unit

    The main method.

    The main method. This stores all argument so that they can be retrieved with args and the executes all initialization code segments in the order they were passed to delayedInit

    args

    the arguments passed to the main method

  25. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  26. final def notify(): Unit

    Definition Classes
    AnyRef
  27. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  28. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  29. def toString(): String

    Definition Classes
    AnyRef → Any
  30. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  31. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  33. def [B](y: B): (App, B)

    Implicit information
    This member is added by an implicit conversion from App to ArrowAssoc[App] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Inherited from DelayedInit

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion StringAdd from App to StringAdd[App]

Inherited by implicit conversion StringFormat from App to StringFormat[App]

Inherited by implicit conversion Ensuring from App to Ensuring[App]

Inherited by implicit conversion ArrowAssoc from App to ArrowAssoc[App]

Ungrouped