Running scala as a scripting language

If you ever want to try out scala, or even if you just want to write a quick scripts that utilizes some native java code, the scala interpreter might be a great choice. After you install scala, instead of waiting for your code to compile, just run your code as a script.

exec scala "$0" "$@"

import java.util.ArrayList

object MyScript {
    def main(args: Array[String]) {
        val a:ArrayList[String] = new ArrayList[String]
        // add the arguments
        for(arg <- args) a.add(arg)
        // add some extra args
        a.add("first extra argument")
        a.add("second extra argument")
        for( e <- a.toArray() ) println("arg: "+e)