shhhgg
Last Updated: February 25, 2016
·
798
· amirtcheva
Dd1ca1288610b1750af31b0f22a51d6c

Passing command line arguments in Scala REPL

First, create the array of command line arguments:

scala> val args = Array("1")
args: Array[String] = Array(1)

Then call your main function (which just prints out all the arguments):

scala> MyFunc.main(args)
1

If you need to add more arguments, you can just initialize with a larger array, or add more to the existing argument array:

scala> args :+ "2"
res2: Array[String] = Array(1, 2)

scala> MyFunc.main(args)
1
2
Say Thanks
Respond