粘贴到REPL中:粘贴

时间:2013-08-14 02:26:39

标签: scala read-eval-print-loop

查看此SO post,我尝试将以下代码粘贴到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命令行,以下输出:

  

阶> :粘贴//进入粘贴模式(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下载
  虚拟隐藏确保功能
  清单地图NoManifest   OptManifest Pair Set
  String Triple root
  arrayToCharSequence asInstanceOf断言
  假设augmentString bin ch
  classManifest classOf com

由于我认为,当我尝试粘贴时,这种意外的输出行为不会编译。

1 个答案:

答案 0 :(得分:1)

检查那里是否有TAB字符。按TAB键时,sbt会触发代码完成。它也以粘贴模式运行。所以它可能试图完成你的陈述并完成错误。