0

I am studying Scala and I am using Scala for win 10

I have write a script "helloarg.scala" with 1 line println("Hello, " + args(0) + "!")

When i used cmd to run file (not in scala shell), it worked.

C:\Users\Darkntnt>scala D:\Scala\helloarg.scala planet

Hello, planet!

However, It got the error when i load file from scala shell

Error:
scala> :load D:\Scala\helloarg.scala planet

usage: :load -v file

Please help me to fix this problem. Thank you.

1 Answer 1

3

That's a good one.

:load doesn't respect args; there are a few different idioms for "run an app as a script".

I'll add this example to the issue about unifying them.

As a workaround, maybe val args = Array("planet") or similar.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.