Getting Started with Scala | The Scala Programming Language

Getting Started with Scala | The Scala Programming Language

Script it !

The above Scala program may also be run as a shell script respectively as a batch command (see the examples in the man pages of the scala command).

The bash shell script script.sh containing the following Scala code (and shell preamble)

  #!/bin/sh
  exec scala "$0" "$@"
  !#
  object HelloWorld {
    def main(args: Array[String]) {
      println("Hello, world! " + args.toList)
    }
  }
  HelloWorld.main(args)
原文地址:https://www.cnblogs.com/lexus/p/2420579.html