0__*_*0__ 6 scala sbt read-eval-print-loop
我记得在某个地方有切换来抑制Scala REPL中返回类型的打印,但我找不到它.我特别感兴趣的是将此开关添加到sbt构建文件中.有点像returnTypes in console := false.
我现在有
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()
Run Code Online (Sandbox Code Playgroud)
而且出于明显的原因,我想要
scala> within( Span( 0, 33 ))
res7: Vector()
Run Code Online (Sandbox Code Playgroud)
我的问题基本上反映在这个邮件列表问题上.根据Rex Kerr的想法,以下内容可以进入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
}
"""
Run Code Online (Sandbox Code Playgroud)
但遗憾的是,在控制台启动并运行后,仍需要手动执行以下三个REPL转义命令:
:power
:wrap shortresults
:silent
Run Code Online (Sandbox Code Playgroud)