I have some code:
object Main extends App
{
val NameTemplate = \"\"\"^([A-Za-z]+)_(\\d+)\\.png\"\"\".r
override def main (args:Array[String])
{
The DelayedInit
trait (which App
extends) causes rewriting of intialisation code to execute within a special delayedInit()
method. This would then normally be invoked by main
. Since you are overriding main
, however, the delayedInit()
code is never being invoked, and as such your value is not being initialised.
As @tenshi explains, you can get around this either by not extending App
or by moving your main code into the body of your Main
object.