Seite 1 von 1
Scala Script Issue
Verfasst: 28. Apr 2015 17:52
I need a small help regarding an issue while executing a Scala script.
I am trying to run a scala script (named Hey.scala) which contains only the code: args.foreach(println)
From the console I run this command:
scala Hey.scala Scala is really fun!!!!!
Could you please tell me why exclamation marks got disappeared?
Re: Scala Script Issue
Verfasst: 28. Apr 2015 18:01
your problem is not scala related. You run the scala interpreter and pass additional arguments. Now bash (or whatever terminal you are using) is interpreting every word as a separate argument. The ! is a reserved keyword though... This is why it will not be printed. In bash it will even throw an error message...
What you can do is surround your arguments in single quotes ('). Then you will get the expected result:
Also make sure to pass the name of the object that contains the main method as the second parameter after the name (I assume it is called Hey here).