3

In python this works:

 clear = lambda: os.system('cls')
 clear()

How would I do that in scala?

Sunny
  • 605
  • 10
  • 35

4 Answers4

6

For REPL there is :keybindings, Ctrl + L clears the screen.

hellraiser
  • 1,451
  • 12
  • 19
5

Using REPL started from a bash shell:

scala> import scala.sys.process._
import scala.sys.process._

scala> def clear() = "clear".!
clear: ()Int

scala> clear()
Carl
  • 826
  • 1
  • 7
  • 14
3

How about print("\u001b[2J")?

dk14
  • 22,206
  • 4
  • 51
  • 88
  • Nice! Or `print("\u001b[2J"); print("\u001b[H")` seems to have the same behavior as `"clear.!` mentioned above (clear console and move to the top left). – Tyler Sep 08 '19 at 21:27
0

use this code. print("\033c") this removes all charset

it will clear away everything in the Scala REPL.

Nugget
  • 58
  • 7