Pasting into REPL with :paste

别来无恙 提交于 2019-12-12 01:28:09

问题


Looking at this SO post, I tried to paste the following code into Putty and Windows command line.

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

However, even though I'm simply pasting into Putty and Windows 7 command line, the following gets output:

scala> :paste // Entering paste mode (ctrl-D to finish)

def size(root: Leaf, left: Branch, right: Branch) : Int = { def go(branch: Branch, acc: Int) : Int = branch match { case Nil => acc

=:= AnyRef ArrowAssoc Class ClassManifest Downloads
DummyImplicit Ensuring Function
Manifest Map NoManifest OptManifest Pair Set
String Triple root
arrayToCharSequence asInstanceOf assert
assume augmentString bin ch
classManifest classOf com

It's not compiling due to, I believe, this unexpected output behavior when I try to paste.


回答1:


Check whether there are TAB characters in there. sbt triggers code completion when you press TAB. It does it also in paste mode. So it might have tried to complete your statement and completed it wrong.



来源:https://stackoverflow.com/questions/18222272/pasting-into-repl-with-paste

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!