One, the application
To run a Scala object, you must provide the name of a stand-alone object. This standalone object needs to contain a Main method that takes a array[string] as a parameter and the result type is unit.
Import checksumaccumulator.calculateobject summer{ = { for (Arg <- args) println (Arg+ ":" +Calculate (ARG));} }
Second, app features
We can add the extends app to get app features behind a single object.
Using the app feature, we can write the code written in the main method directly in the curly braces of the singleton object without having to write the main method.
You can access command-line arguments through a string array called args.
Then we can compile and run it like any other application.
Importextends app{ for (Arg <-List ("Fall", "Winter", "Spring ")) println (Arg+ ":" +Calculate (ARG));}
7. App and app features