title: Swift Array of Functions
body: <p>I'm very new to Swift, but slowly learning by following the <a href="https://itunes.apple.com/us/course/developing-ios-8-apps-swift/id961180099" rel="nofollow noreferrer">Stanford iTunes U course</a>. I have a question about storing and calling functions in an array.</p>
  
  <p>The code I have (below) seems to store the function properly, but when I try to call one of the functions I get this error: <code>'(IntegerLiteralConvertible, IntegerLiteralConvertible) -&gt; $T6' is not identical to (String, Op)</code>.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/24418951/array-of-functions-in-swift#24447484">this answer</a> that was helpful in getting to where I am, but now I'm stuck.</p>
  
  <pre><code>enum Op {
      case binary((Double, Double) -&gt; Double)
  }
  
  var ops = [String: Op]()
  
  func addOperation(symbol: String, op: Op) {
      ops[symbol] = op
  }
  
  addOperation("×", Op.binary(*))
  addOperation("÷", Op.binary({ $1 / $0 }))
  addOperation("+", Op.binary(+))
  addOperation("−", Op.binary({ $1 - $0 }))
  
  var newValue = ops["÷"](6, 3) // Produces the error
  </code></pre>
  
  <p>My understanding was that <code>ops["÷"]</code> should be the function I stored in the array earlier. Am I not calling it properly?</p>