查看这篇 SO帖子,我尝试将以下代码粘贴到 Putty 和 Windows 命令行中。
def size(root: Leaf, left: Branch, right: Branch) : Int = {
def go(branch: Branch, acc: Int) : Int = branch match {
case Nil => acc
case branch.left != Nil && branch.right != Nil => go(branch.left, acc) +
go(branch.right, acc)
case branch.left != Nil => go(branch.left, acc)
case branch.right != Nil => go(branch.right, acc)
case _ => 0
}
root match {
case Nil => go(left, 0) + go(right, 0)
case _ => 1 + go(left, 0) + go(right, 0)
}
}
但是,即使我只是粘贴到 Putty 和 Windows 7 命令行中,也会得到以下输出:
scala> :paste // 进入粘贴模式(ctrl-D 完成)
def size(root: Leaf, left: Branch, right: Branch) : Int = { def go(branch: Branch, acc: Int) : Int = branch match { case Nil => acc
=:= AnyRef ArrowAssoc 类 ClassManifest 下载
DummyImplicit Ensuring Function
Manifest Map NoManifest OptManifest Pair Set
String Triple root
arrayToCharSequence asInstanceOf assert
假设 augmentString bin ch classManifest
classOf com
我相信,当我尝试粘贴时,它不会编译,因为这种意外的输出行为。