6

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()

そして明らかな理由で私は欲しい

scala> within( Span( 0, 33 ))
res7: Vector()
4

1 に答える 1

5

私の質問は基本的にこのメーリングリストの質問に反映されています。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
}
"""

ただし、残念ながら、コンソールが起動して実行された後は、次の3つのREPLエスケープコマンドを手動で実行する必要があります。

:power
:wrap shortresults
:silent
于 2012-06-17T00:19:39.080 に答える