title: Swift doesn't recognize recursive call to function, thinks it's a local variable
body: <p>I am following along with the Stanford Swift course on iTunes.  I am in lesson 3 where the professor writes a recursive function to evaluate a stack of operators and operands.</p>
  
  <p>Here is the code as the professor has typed it:</p>
  
  <pre><code>class CalculatorBrain
  {
     private enum Op {
         case Operand(Double)
         case UnaryOperation(String, Double -&gt; Double)
         case BinaryOperation(String, (Double, Double) -&gt; Double)
     }
  
     private var opStack = [Op]()
  
     private var knownOps = [String:Op]()
  
     init() {
      knownOps["×"] = Op.BinaryOperation("×", *)
      knownOps["+"] = Op.BinaryOperation("+", +)
      knownOps["-"] = Op.BinaryOperation("-") { $1 - $0 }
      knownOps["÷"] = Op.BinaryOperation("÷") { $1 / $0 }
      knownOps["√"] = Op.UnaryOperation("√", sqrt)
     }
  
     func pushOperand(operand: Double) {
        opStack.append(Op.Operand(operand))
     }
  
     func performOperation(symbol: String) {
        if let operation = knownOps[symbol] {
          opStack.append(operation)
        }
     }
  
     private func evaluate(ops: [Op]) -&gt; (result: Double?, remainingOps: [Op])
     {
      var remainingOps = ops
      if !remainingOps.isEmpty {
          let op = remainingOps.removeLast()
          switch op {
          case .Operand(let operand):
              return (operand, remainingOps)
          case .UnaryOperation(_, let operation):
              let operandEvaluation = evaluate(remainingOps)
              if let operand = operandEvaluation.result {
                  return (operation(operand), operandEvaluation.remainingOps)
              }
          case .BinaryOperation(_, let operation):
          // code snipped
          }
      }
      return (nil, ops)
     }
  }
  </code></pre>
  
  <p>I get a compiler error but he doesn't.</p>
  
  <p>The error I get is on the line <code>let operandEvaluation = evaluate(remainingOps)</code>.  I get the error "Use of local variable 'evaluate' before its declaration"</p>
  
  <p>Does anyone know why I'm getting this error?  It's supposed to be a recursive call to the function <code>evaluate</code>, but instead the compiler thinks <code>evaluate</code> is a local variable.</p>
  
  <p>I am using Xcode 6.4 on OS X 10.10.4</p>
  
  <p>Thanks!</p>