No explicit main method is needed. Instead, the whole class body becomes the “main method”.
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.'''''
Future versions of this trait will no longer extend DelayedInit.
Attributes
Authors:
Martin Odersky
Since
2.1
Deprecated
[Since version 3.8.0] Support for trait App is deprecated in Scala 3. Please refer to https://docs.scala-lang.org/scala3/book/methods-main-methods.html.
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.
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.
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.
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.
Value parameters
body
the initialization code to be stored for later execution
Attributes
Deprecated
[Since version 2.11.0] the delayedInit mechanism will disappear