In Scala 3 I can specify a main method which gets one parameter like this:
@main
def main(mode: String): Unit = ???
If I run it without specifying the argument, I would get “Illegal command line: more arguments expected”. Fine.
Now if I specify a default value like this
@main
def main(mode: String = "all"): Unit = ???
then I still get that same error.
- Why is that?
- And why doesn’t the compiler complain if default
values are not possible in main method arguments? To just ignore them doesn’t seem useful to me.
Tried with Scala 3.4.2.