[Original] Scala learning: compiling Scala scripts

Source: Internet
Author: User

Scala supports scripts

1) create a file hello. Scala under/opt/Scala-script and edit the file as follows:

$ Hello, this is the first Scala script

2) run the script

    

 

The command line parameters of the scala script are saved in the scala array named args. In Scala, the array uses0You can specify the index value in brackets to access array elements. The first element of the array ARGs in Scala is: ARGs (0), rather than: ARGs [0] Like java. Now, write the following content to the new file:

Test hellowithargs. scala:

// Send Hello println ("Hello:" + ARGs (0) to the first parameter ))

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

[Email protected]:/opt/Scala-script # Scala hello. Scala
Java.net. unknownhostexception: scala: Unknown error
At java.net. inetaddress. getlocalhost (inetaddress. Java: 1505)
At scala. Tools. nsc. Io. Socket $. localhost (socket. scala: 28)
At scala. Tools. nsc. compilesocket. getsock $1 (compilesocket. scala: 175)
At scala. Tools. nsc. compilesocket. getorcreatesocket (compilesocket. scala: 190)
At scala. Tools. nsc. scriptrunner. compilewithdaemon (scriptrunner. scala: 70)
At scala. tool. nsc. scriptrunner. Scala $ tools $ NSC $ scriptrunner $ compile $1 (scriptrunner. scala: 113)
At scala. Tools. nsc. scriptrunner $ anonfun $ withcompiledscript $1. Apply $ mcz $ Sp (scriptrunner. scala: 161)
At scala. Tools. nsc. scriptrunner $ anonfun $ withcompiledscript $1. Apply (scriptrunner. scala: 129)
At scala. Tools. nsc. scriptrunner $ anonfun $ withcompiledscript $1. Apply (scriptrunner. scala: 129)
At scala. Tools. nsc. util. Package $. trackingthreads (package. scala: 43)
At scala. Tools. nsc. util. Package $. waitingforthreads (package. scala: 27)
At scala. Tools. nsc. scriptrunner. withcompiledscript (scriptrunner. scala: 128)
At scala. Tools. nsc. scriptrunner. runscript (scriptrunner. scala: 192)
At scala. Tools. nsc. scriptrunner. runscriptandcatch (scriptrunner. scala: 205)
At scala. Tools. nsc. maingenericrunner. runtarget $1 (maingenericrunner. scala: 67)
At scala. Tools. nsc. maingenericrunner. run $1 (maingenericrunner. scala: 87)
At scala. Tools. nsc. maingenericrunner. Process (maingenericrunner. scala: 98)
At scala. Tools. nsc. maingenericrunner $. Main (maingenericrunner. scala: 103)
At scala. Tools. nsc. maingenericrunner. Main (maingenericrunner. Scala)
Caused by: java.net. unknownhostexception: scala: Unknown error
At java.net. inet6addressimpl. lookupallhostaddr (native method)
At java.net. inetaddress $2. lookupallhostaddr (inetaddress. Java: 928)
At java.net. inetaddress. getaddressesfromnameservice (inetaddress. Java: 1323)
At java.net. inetaddress. getlocalhost (inetaddress. Java: 1500)
... 18 more

[Original] Scala learning: compiling Scala scripts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.