发布时间:2022-08-09 文章分类:编程知识 投稿人:李佳 字号: 默认 | | 超大 打印

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)