Questions tagged [scala-repl]
40 questions
2
votes
1 answer
Is it instance name/id that scala REPL prints?
Tutorial mentions about mutable sets in the initial but why would the REPL change the instance name from res4 to res5 when a new element is added? Is 'res' not the instance name that REPL prints? Below is the code in context. Beginner in scala.…

nashter
- 1,181
- 1
- 15
- 33
2
votes
1 answer
Disable deprecation warnings in the Scala REPL
Is it possible to disable deprecation warnings in the Scala REPL?
E.g. when I type:
scala> List(1,2,3).toSet()
I get a deprecation warning:
:12: warning: Adaptation of argument list by inserting () is deprecated: this is unlikely to be…

Florian Baierl
- 2,378
- 3
- 25
- 50
2
votes
1 answer
Backspace key doesn't work in Scala REPL on macOS
In macOS Mojave's Terminal, the backspace key doesn't function as it should in the Scala 2.12.7 REPL (installed via Homebrew).
This link suggests using scala -Dinput.encoding=iso-8859-1 to start the REPL, however, it doesn't work in this case. I've…

LShi
- 1,500
- 16
- 29
2
votes
1 answer
How to use `asRight` to create Either instance with cats
I am trying to create an instance of Either using asRight in REPL:
import cats._
import cats.data._
import cats.implicits._
scala> val x = "xxx".asRight
:20: error: value asRight is not a member of String
val x = "xxx".asRight
…

Michael
- 41,026
- 70
- 193
- 341
2
votes
1 answer
Nested environments in Scala REPL
Is it possible to create (enter) nested environments in Scala REPL, such that after exiting the nested environment, all variable bindings created within the exited environment will be lost?
Here is what I wish a session could look like:
scala> val x…

Tomas Mikula
- 6,537
- 25
- 39
2
votes
1 answer
Unable to use scala's repl :javap to look at trait companion object
I am using the :javap command in the scala repl and was trying to look at the traits companion object, but I couldn't seem to find out how. Here is what I do from command line.
$ cat > Foo.scala <

ekaqu
- 2,038
- 3
- 24
- 38
1
vote
1 answer
Why my function on Scala REPL is print as 'Lambda'?
I created this function on Scala REPL
scala> val multiDouble = (input :Double) =>
| {
| val toMulti = 2;
| toMulti * input
| }: Double
And the output is val multiDouble: Double => Double =…

Catarina Nogueira
- 1,024
- 2
- 12
- 28
1
vote
2 answers
val behavior in scala REPL and Intellij
as expected reassignment is giving error like below in REPL
scala> val a=1
a: Int = 1
scala> a=2
:12: error: reassignment to val
a=2
^
But the below reassignment is not giving error in REPL when a=2 preceded with…

dsk
- 13
- 2
1
vote
2 answers
Scala REPL truncates the output
I would like to know if is there any way to avoid that Scala REPL truncates the output by setting a environment variable or whatever?
Example
scala> typeOf[Iterator[_]].members.mkString("\n")
res6: String =
override def toString(): String
def…

Chema
- 2,748
- 2
- 13
- 24
1
vote
1 answer
Embedding scala 2.13.x REPL
For Scala 2.12.x one could use scala.tools.nsc.interpreter.ILoop to embed the Scala REPL. With Scala 2.13.x scala.tools.nsc.interpreter.ILoop has been removed. How could one embed the Scala 2.13.x REPL?

collymy
- 77
- 7
1
vote
1 answer
Scala setter and getters
Considering this trait 'Person' and this class 'PersonImpl':
trait Person {
def name: String
def surname: String
def married: Boolean
def married_=(state: Boolean): Unit
override def toString(): String = name + " " + surname + " " +…

Giacomo Bartoli
- 730
- 3
- 9
- 23
0
votes
0 answers
Spark and CSV: How can you tell from an inferred schema which columns allow null?
After you have loaded a CSV file into Spark. And you are exploring from the Scala REPL. How can you tell which Columns have allowed Nulls and which ones haven't?

BuddyJoe
- 69,735
- 114
- 291
- 466
0
votes
1 answer
Is there any way to install Scala Ammonite-REPL in Windows 8.1
I'm looking for how to install Scala Ammonite-REPL in Windows 8.1 but I didn't find anything in the web.
does anyone know something related about this?
Is there any way to do this?

Chema
- 2,748
- 2
- 13
- 24
0
votes
1 answer
Scala class of out-of-class method
If scala methods belong to classes, how come can one create a method outside of a class?
As in:
def hello(a:String) {println(s"Hello $a")}
What class does this method belong to?
And why is there such a concept (method outside of class) at all? My…

Michele Piccolini
- 2,634
- 16
- 29
0
votes
1 answer
How to load and use native library in scala repl?
When you use scala repl simple call System.loadLibrary("opencv_410") (in case you are trying to load libopencv_410.so) does not make you able to use native library. If you try to create some object of the class with JNI calls it will tell you ---…

Vladimir Protsenko
- 1,046
- 2
- 14
- 21