Trait

scala

App

Related Doc: package scala

Permalink

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 should not be overridden: the whole class body becomes the "main method".

Future versions of this trait will no longer extend DelayedInit.

Version

2.1, 15/02/2011

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. App
  2. DelayedInit
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def args: Array[String]

    Permalink

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

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

    Attributes
    protected
    Annotations
    @deprecatedOverriding( "args should not be overridden" , "2.11.0" )
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

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

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

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

    Permalink

    The main method.

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

    args

    the arguments passed to the main method

    Annotations
    @deprecatedOverriding( "main should not be overridden" , "2.11.0" )
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

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

    Permalink
    Definition Classes
    AnyRef
  18. def toString(): String

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

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def delayedInit(body: ⇒ Unit): Unit

    Permalink

    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
    Annotations
    @deprecated
    Deprecated

    (Since version 2.11.0) The delayedInit mechanism will disappear.

Inherited from DelayedInit

Inherited from AnyRef

Inherited from Any

Ungrouped