title: Error on scala class : recursive method printExpr needs result type
body: <p>I'm getting an error on line : </p>
  
  <pre><code>case Sum(l, r) =&gt; printExpr(l); print("+"); printExpr(r)
  </code></pre>
  
  <p>error is : </p>
  
  <blockquote>
    <p>recursive method printExpr needs result type</p>
  </blockquote>
  
  <p>This code looks ok to me, what am I doing wrong ?</p>
  
  <pre><code>abstract class Expr {
  
    case class Num(n: Int) extends Expr
    case class Sum(l: Expr , r: Expr) extends Expr
    case class Prod(l: Expr, r: Expr) extends Expr
  
    def evalExpr(e: Expr): Int = e match {
      case Num(n) =&gt; n
      case Sum(l, r) =&gt; evalExpr(l) + evalExpr(r)
      case Prod(l, r) =&gt; evalExpr(l) * evalExpr(r)
    }
  
    def printExpr(e: Expr) = e match {
      case Num(n) =&gt; print(" " + n + " ")
      case Sum(l, r) =&gt; printExpr(l); print("+"); printExpr(r)
      case Prod(l, r) =&gt; printExpr(l); print("x"); printExpr(r)
    }
  }
  </code></pre>