scala-script

Shorter Scala Script header

北慕城南 提交于 2019-12-21 00:12:14
问题 It's possible to write shell scripts in Scala by starting a text file with: #!/bin/sh exec scala "$0" "$@" !# To ease script creation, I would like to write an executable called scalash (perhaps a BASH script) allowing to shorten Scala script header to just one line: #!/bin/scalash Is it possible ? Extra points if I can pass optional parameters to scalash , for instance to add classpath dependencies. 回答1: In Scala 2.11, you can do it as follows (exactly as with most other languages): #!/usr

Scala script doesn't run on Ubuntu

て烟熏妆下的殇ゞ 提交于 2019-12-07 13:20:15
问题 I have a previously working Scala script that when I try to run it on a new PC, the compilation fails. So I made simple script to test: #!/bin/sh exec scala -J-Xmx2g "$0" "$@" !# println("test") And trying to run it I get: test.scala error: Compile server encountered fatal condition: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer; java.lang.NoSuchMethodError: java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer; at scala.tools.nsc.io.SourceReader.read(SourceReader.scala:61) at scala.tools.nsc.io

Shorter Scala Script header

孤街醉人 提交于 2019-12-03 06:41:29
It's possible to write shell scripts in Scala by starting a text file with: #!/bin/sh exec scala "$0" "$@" !# To ease script creation, I would like to write an executable called scalash (perhaps a BASH script) allowing to shorten Scala script header to just one line: #!/bin/scalash Is it possible ? Extra points if I can pass optional parameters to scalash , for instance to add classpath dependencies. In Scala 2.11, you can do it as follows (exactly as with most other languages): #!/usr/bin/env scala println(args.mkString(" ")) In Scala 2.9.0.1, you can simply create the following script: test

What is the difference between scala classes, scripts and worksheets in Intellij-idea?

若如初见. 提交于 2019-11-30 11:06:13
I'm using Intellij-idea for scala programming (with sbt plugin). I want to know what is the difference between scala classes, scala scripts and scala worksheets. When we use each of them? This will be very nice if you can explain it by a simple example. Thanks You have different ways of running scala code: First create a Program with your classes, this is as in java, I use object because it works well without instantianing, like static, just compile with the SBT and run it you can also use the scala Interpreter REPL We can use this object in the REPL scala> object Hello { | def main(args:Array

What is the difference between scala classes, scripts and worksheets in Intellij-idea?

筅森魡賤 提交于 2019-11-29 17:07:03
问题 I'm using Intellij-idea for scala programming (with sbt plugin). I want to know what is the difference between scala classes, scala scripts and scala worksheets. When we use each of them? This will be very nice if you can explain it by a simple example. Thanks 回答1: You have different ways of running scala code: First create a Program with your classes, this is as in java, I use object because it works well without instantianing, like static, just compile with the SBT and run it you can also