question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem running `@main` methods with command line arguments

See original GitHub issue

Compiler version

3.1.1

Minimized code

// In file echoargs.scala
@main def echo(args: String*) =
  println(args.mkString(" "))

Output

First compile

$ scalac echoargs.scala

Then run the main method:

$ scala echo hello world
echo hello world hello world

Expectation

$ scala echo hello world
hello world

Edit: this was the output using the scala command of 3.0.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
som-snyttcommented, Feb 22, 2022
$ scala echo hello world
echo hello world hello world

Crossword just had clue “hello hello hello, e.g.” for “echo”.

1reaction
spamegg1commented, Feb 22, 2022

If we can go 6 months without using command line args, then maybe we don’t need command line args.

The book told me to do it! (Prog in Scala 5th ed) It’s used to show the power of type classes:

How does Scala know how to turn the command line string “3” into an Int 3 ? It uses a typeclass named FromString ,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Main() and command-line arguments | Microsoft Learn
Learn about Main() and command-line arguments. The 'Main' method is the entry point of an executable program.
Read more >
Getting an error running this program as a command line ...
Try Below Code: public class SumOfNumbers { public static void main(String[] args) { int[] intArgs = new int[args.length]; for (int x = 0; ......
Read more >
Make sure that command line arguments are used safely here ...
How to fix issue in Spring boot main method: Make sure that command line arguments are used safely here - SonarQube - Sonar...
Read more >
Command Line Arguments in Java - DigitalOcean
Command -line arguments in Java are used to pass arguments to the main program. If you look at the Java main method syntax,...
Read more >
The Main method | Command line arguments in Java - YouTube
Java Tutorial - Java Command Line Argument Playlist link (You can download Java example code from each video description from this ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found