使用Scala REPL时,我有时会收到所有变量的意外转储。我认为这种情况大多发生在(粘贴模式)下(总是会发生)。
如果我后来想要在我的窗口中向后滚动以查看我之前所做的事情,因为Windows命令窗口中的历史记录有限,这有点令人讨厌。
要重现,我会执行以下步骤。
首先,我在Windows 8.1(唉,它在我的新机器上)命令窗口内启动scala REPL。
然后输入:paste。
进入粘贴模式第三,我粘贴了以下简单的Scala代码。
// Find the minimum and maximum of an array using foldLeft
{
val nums = Array[Int](1, 4, 7, 2, 9, 3, -2, 5, 11, 4, 6)
def minmax( nums : Array[Int] ) : (Int, Int) = {
nums.foldLeft((nums(0),nums(0))) (
(n, m) => {
(n._1 min m, n._2 max m)
}
)
}
minmax( nums )
}
最后(尽管问题现在可见),我按ctrl-D退出粘贴模式。
在步骤3中执行粘贴之后,在步骤4之前,以下内容被转储到屏幕上:
scala> :paste
// Entering paste mode (ctrl-D to finish)
{
val nums = Array[Int](1, 4, 7, 2, 9, 3, -2, 5, 11, 4, 6)
def minmax( nums : Array[Int] ) : (Int, Int) = {
nums.foldLeft((nums(0),nums(0))) (
(n, m) => {
$intp assume println
??? augmentString quicktime
ArrayCharSequence classManifest readBoolean
ArrowAssoc classOf readByte
... multiple rows of symbols deleted for brevity ...
arrayToCharSequence org unwrapString
asInstanceOf print
assert printf
(n._1 min m, n._2 max m)
}
)
}
minmax( nums )
}
关于触发此转储的内容以及我将来可能采取哪些措施来避免它的任何想法?我可以发现它似乎没有任何押韵或理由。
由于 TJ