为什么我不能模式匹配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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
更新:
代码是99个scala问题的逐字副本
我收到这个编译时错误:
BinaryTree.scala:25: '=>' expected but '[' found.
[error] case Node[T] => {
[error] ^
[error] one error found
Run Code Online (Sandbox Code Playgroud)
25号线指向该线
case Node[T] => {
Run Code Online (Sandbox Code Playgroud) scala ×1