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
Written by Alexandra Mirtcheva
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Scala
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#