July 2017
Intermediate to advanced
796 pages
18h 55m
English
The scala command executes the bytecode that is generated by the interpreter:
$ scala HelloWorld
Scala allows us to specify command options, such as the -classpath (alias -cp) option:
$ scala -cp classes HelloWorld
Before using the scala command to execute your source file(s), you should have a main method that acts as an entry point for your application. Otherwise, you should have an Object that extends Trait Scala.App, then all the code inside this object will be executed by the command. The following is the same Hello, world! example, but using the App trait:
#!/usr/bin/env Scala object HelloWorld extends App { println("Hello, world!") }HelloWorld.main(args)
The preceding script can be run directly from the ...
Read now
Unlock full access