【发布时间】:2010-12-27 18:22:31
【问题描述】:
为什么我不能对 Node[T] 进行模式匹配?
object Visitor {
def inorder[T](root: Node[T]) : Unit = {
root match {
case End => return;
case Node[T] => {
if( root.left != null )
inorder( root.left )
println( root.toString );
inorder( root.right );
}
case _ => return;
}
}
}
更新:
代码是来自99 scala problems的逐字复制
我收到了这个编译时错误:
BinaryTree.scala:25: '=>' expected but '[' found.
[error] case Node[T] => {
[error] ^
[error] one error found
第 25 行指向该行
case Node[T] => {
【问题讨论】:
标签: scala