请问如下代码为什么会编译报错?该如何修改?
错误信息
```
Error:(11, 21) missing parameter type for expanded function
The argument types of an anonymous function must be fully known. (SLS 8.5)
```
问题代码
```
object Main extends App {
  var tokens = Array("10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+")
  println(Solution.evalRPN(tokens))
}
object Solution {
  def evalRPN(tokens: Array[String]): Int = {
    val stack = new scala.collection.mutable.Stack[Int]
    tokens.foreach(token =>
      token matches {
        case "+" => stack.push(stack.pop() + stack.pop())
        case "-" => stack.push(-stack.pop() + stack.pop())
        case "*" => stack.push(stack.pop() * stack.pop())
        case "/" => {
          val top = stack.pop();
          stack.push(stack.pop() / top)
        }
        case _ => stack.push(stack.pop())
      })
    stack.pop()
  }
}```
相似问题