Amain
is the method that is being called to start your program. It needs a specific structure – calledprototypewhen talking about methods – to be recognized.
Until now we ran all the SKBs inWorksheetmode which hides themain
from us.
If you have tried to remove or change themain
function, you might have noticed an exception:
java.lang.RuntimeException: No main class detected.
ThisException
will be thrown if amain
method cannot be found or is not contained within anobject
. Try to change the code to trigger it.
The main prototype is always of the form:
def main(args: Array[String]): Unit = { }The
args: Array[String]
is where you would be able to read and use the arguments given to the application when started.That is pretty much it concerningmain
, so I thought it would be nice to combine some of the things we’ve seen in the past. This SKB is usingMap
,object
,Option
,lazy val
,def
all into the same project. Try to play with it and make it your own.