Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear all variables in Scala REPL

Is there a quick command? I don't want to Ctrl+d and run Scala everytime I want to clear all variables. reset, clear and clean don't work and :help doesn't have anything listed

like image 302
Plasty Grove Avatar asked Jan 12 '13 09:01

Plasty Grove


People also ask

What is RES in scala?

res in scala shell are val. you can verify this by trying to reassign a value to res. e.g. - scala> List(1)

How do you clear a scala REPL?

Implementing it wouldn't be hard, either! I believe Ctrl + L should be able to clear the REPL console.

What is REPL in scala?

The Scala REPL (Read-Eval-Print-Loop) is a development tool to interpret fragments of Scala code. It doesn't require too much setup or infrastructure and it is going to be essential during your learning journey. Using the REPL, you'll be able to play and experiment with the language by typing and evaluating code.

How does scala REPL work?

The Scala REPL is a tool (scala) for evaluating expressions in Scala. The scala command will execute a source script by wrapping it in a template and then compiling and executing the resulting program.


1 Answers

You can use :reset

Welcome to Scala version 2.10.0-RC2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37). Type in expressions to have them evaluated. Type :help for more information.  scala> val a = 1 a: Int = 1  scala> val b = 3 b: Int = 3  scala> :reset Resetting interpreter state. Forgetting this session history:  val a = 1 val b = 3  Forgetting all expression results and named terms: $intp, a, b  scala> 
like image 169
tenshi Avatar answered Sep 23 '22 11:09

tenshi