How to clear all variables in Scala REPL

Plasty Grove picture Plasty Grove · Jan 12, 2013 · Viewed 10.9k times · Source

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

Answer

tenshi picture tenshi · Jan 12, 2013

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>