I remember there is switch somewhere to suppress the printing of return types in the Scala REPL, but I cannot find it. I am particularly interested in adding this switch to an sbt build file. Something like returnTypes in console := false
.
E.g. now I have
scala> within( Span( 0, 33 ))
res7: scala.collection.immutable.IndexedSeq[(de.sciss.lucre.expr.SpanLike, scala.collection.immutable.IndexedSeq[(de.sciss.lucre.expr.Expr[de.sciss.lucre.stm.InMemory,de.sciss.lucre.expr.SpanLike], de.sciss.lucre.expr.Expr[de.sciss.lucre.stm.InMemory,Long])])] = Vector()
and for obvious reasons I want
scala> within( Span( 0, 33 ))
res7: Vector()
My question is basically mirrored by this mailing-list question. Based on Rex Kerr's idea, the following could go into build.sbt
:
initialCommands in console := """// helper method to disable type printing
def shortresults[T](t: => T) = {
val s = t.toString
val name = s.takeWhile(_ != ':')
val idx = s.indexOf(" = ")
val full = if (idx >= 0) name + s.substring(idx) else s
val short = if (full.length>799) full.substring(0,796)+"..." else full
print(short)
t
}
"""
But unfortunately, still the following three REPL escape commands need to be manually executed after the console is up and running:
:power
:wrap shortresults
:silent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With