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

Future versions of this trait will no longer extend `DelayedInit`.

Source
  App.scala
Version

  2.1, 15/02/2011

Linear Supertypes
DelayedInit, AnyRef, Any
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 any2stringadd
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: Any): Boolean

   Definition Classes
     AnyRef → Any

2. #### final def ##(): Int

   Definition Classes
     AnyRef → Any

3. #### def +(other: String): String

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

4. #### 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()

5. #### final def ==(arg0: Any): Boolean

   Definition Classes
     AnyRef → Any

6. #### 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
   Annotations
     @deprecatedOverriding( "args should not be overridden" , "2.11.0" )

7. #### final def asInstanceOf[T0]: T0

   Definition Classes
     Any

8. #### def clone(): AnyRef

   Attributes
     protected[java.lang]
   Definition Classes
     AnyRef
   Annotations
     @throws( ... )

9. #### 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

10. #### 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

11. #### 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

12. #### 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

13. #### final def eq(arg0: AnyRef): Boolean

    Definition Classes
      AnyRef

14. #### def equals(arg0: Any): Boolean

    Definition Classes
      AnyRef → Any

15. #### val executionStart: Long

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

16. #### def finalize(): Unit

    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( classOf[java.lang.Throwable] )

17. #### 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()

18. #### final def getClass(): Class[_]

    Definition Classes
      AnyRef → Any

19. #### def hashCode(): Int

    Definition Classes
      AnyRef → Any

20. #### final def isInstanceOf[T0]: Boolean

    Definition Classes
      Any

21. #### def main(args: Array[String]): Unit

    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" )

22. #### final def ne(arg0: AnyRef): Boolean

    Definition Classes
      AnyRef

23. #### final def notify(): Unit

    Definition Classes
      AnyRef

24. #### final def notifyAll(): Unit

    Definition Classes
      AnyRef

25. #### final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
      AnyRef

26. #### def toString(): String

    Definition Classes
      AnyRef → Any

27. #### final def wait(): Unit

    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

28. #### final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

29. #### final def wait(arg0: Long): Unit

    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

30. #### 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

### Deprecated Value Members

1. #### 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
     App → DelayedInit
   Annotations
     @deprecated
   Deprecated

     (Since version 2.11.0) The delayedInit mechanism will disappear.

### Inherited from DelayedInit

### Inherited from AnyRef

### Inherited from Any

### Inherited by implicit conversion any2stringadd from App to any2stringadd[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