Questions tagged [scala-repl]

40 questions
38
votes
6 answers

Ubuntu + scala REPL, Commands not typed on console

I am using Ubuntu 18.04 + Scala 2.11.12 (OpenJDK 64-Bit Server VM, Java 1.8.0_162). Once I open the scala shell, I am not able to see anything that I type. It gets typed though. Below is how it is happening when I type println("Hello, world!") at…
Abhay Dandekar
  • 1,230
  • 10
  • 30
8
votes
3 answers

How to modify previous line in REPL - scala to modify the typing errors to save time compare to entering each line using up/down arrows

There are chances that some typing (in Ubuntu terminal - scala -version Scala code runner version 2.9.1) errors occur, example shown below where instead of (l: Int) (l: int) has been typed in parameters. scala> class Rectangle (l:int, w: Int){ |…
Optimight
  • 2,989
  • 6
  • 30
  • 48
6
votes
1 answer

scala string interpolation for "$"

Why does string interpolation not work when the name of value of '$'? In the following code, why does the value of $ not get printed? What is the mistake when the value of x is printed using string interpolation? repl> val x="test value" repl> val…
nashter
  • 1,181
  • 1
  • 15
  • 33
6
votes
1 answer

Deadlocks with java.util.concurrent._ in Scala in REPL

I came across the following scenario when studying the book "Functional Programming in Scala" by Paul Chiusano and Runar Bjanarson (Ch. 7 - Purely functional parallelism). package fpinscala.parallelism import java.util.concurrent._ …
clog14
  • 1,549
  • 1
  • 16
  • 32
6
votes
1 answer

Scala REPL does not work on Ubuntu

When trying to use the scala interpreter in the terminal I am experiencing a weird issue, when I try to write, the cursor does not move, although after I press enter it "works". This is what I should see: Welcome to Scala 2.11.12 (Java HotSpot(TM)…
6
votes
1 answer

spark-shell: strange behavior with import

I am working in a spark-shell (Spark version 2.1.0, Using Scala version 2.11.8, OpenJDK 64-Bit Server VM, 1.7.0_151). I import Column class: scala> import org.apache.spark.sql.Column import org.apache.spark.sql.Column I can define a Column…
ivankeller
  • 1,923
  • 1
  • 19
  • 20
5
votes
1 answer

Why does following throw exception in Scala REPL?

Why does last line of following piece of code throw error in scala REPL? import scala.concurrent._ import scala.concurrent.duration._ import scala.concurrent.ExecutionContext.Implicits.global // This is okay val futureInt = Future[Int] { 42 } val…
Shamshad Alam
  • 1,684
  • 3
  • 19
  • 31
4
votes
2 answers

Quickly switching Scala versions from CLI

nvm (Node Version Manager) enables quick selection of alternative Node version to work with. Does Scala have a similar way of quickly switching different versions in the current shell? For example, say I want to start REPL with 2.12.10, then…
Mario Galic
  • 47,285
  • 6
  • 56
  • 98
4
votes
4 answers

How to run scala file from command line?

Does scala support scala run xxx.scala? The go language supports running like go my.go and python supports python my.py but it seems scala xxx.scala is only a syntax check, no output or running behavior is observed. So is there a way to run a…
Troskyvs
  • 7,537
  • 7
  • 47
  • 115
3
votes
2 answers

Unable to launch Scala REPL using 'sbt console' due to InvalidPath exception

I am working on Windows 10 OS and installed sbt 1.4.5 from the .msi installer from scala-lang downloads page. Now when I type sbt or sbt about in the command prompt, it works fine but as soon as I type sbt console, I get the following error…
PixieDev
  • 307
  • 7
  • 19
3
votes
1 answer

Why does scala evaluate a type alias when it has a line break and no equals sign?

I notice when declaring a type alias in the REPL, a line break causes a statement to succeed: this works: scala> type a | 3 == 3 defined type alias a res32: Boolean = true This does not: scala> type a 3 == 3 ^ error: `=`,…
Rob
  • 3,333
  • 5
  • 28
  • 71
3
votes
1 answer

Scala and integrated terminal in VS Code

I am using the Scala REPL with the integrated terminal. I open the Scala REPL on the terminal and then send small snippets with workbench.action.terminal.runSelectedText (which I have bound to a shortcut). This works fine when the snippets have to…
3
votes
1 answer

Protect system when using scala interpreter api

I have created simple REPL bot for scala. It runs in linux environment and processes written scala code in dialogs and gives the result: For example user| 1+1 bot | res0: Int = 2 user| res0 + 3 bot | res1: Int = 5 ... I used scala interpreter API…
oybek
  • 630
  • 4
  • 14
3
votes
1 answer

Is it possible to open a interactive vim process by Scala REPL shell command?

I'm exploring to use Scala REPL bridge to shell.It is mainly achieved by import sys.process._ package and I can use "ls" ! to execute shell. Now, I want to use "vi" ! to open a interactive vi editor, it is really crazy but very exciting. After…
LoranceChen
  • 2,453
  • 2
  • 22
  • 48
2
votes
1 answer

Error with floating point literal in Scala REPL

The definiton for floating point literal in Scala is floatingPointLiteral ::= digit {digit} ‘.’ digit {digit} [exponentPart] [floatType] | ‘.’ digit {digit} [exponentPart] [floatType] | digit…
1
2 3