Search code examples
scalaread-eval-print-loop

Avoid a .toString call in REPL?


I have this class with a .toString method, that generates a huge JSON object, and caches it in a lazy val ... Trying to investigate some weirdness going on with that json generation, I want to create an instance of the object in REPL, but not have .toString called just yet.

What I came up with is this:

 class Foo(val x: MyActualClass)
 val foo = new Foo(new MyActualClass)

I wonder if there is a better way. Like is there some command to just tell REPL I don't want to print out the results of the assignments for example?


Solution

  • You can use :silent to do this:

    :silent disable/enable automatic printing of results