title: Declare a function in Swift before defining it
body: <p>If I run this code in the Swift playground it works fine. The function is defined before it is called.</p>
  
  <pre><code>import Cocoa
  
  func addValues(valueA:Double, valueB:Double)
  {
      let result = valueB + valueB
      println("Result \(result)")
  }
  
  addValues(23.83, 87.12)
  </code></pre>
  
  <p>If I try to call the function before it is defined I get an error message. Not unexpected because the function is still unknown to the compiler. (For some reason it still seems to work)</p>
  
  <pre><code>import Cocoa
  
  addValues(23.83, 87.12)
  
  func addValues(valueA:Double, valueB:Double)
  {
      let result = valueB + valueB
      println("Result \(result)")
  }
  </code></pre>
  
  <p>In Objective-C I was able to declare the function head only on top of the file and define the function later at the end of the code. So the second version of my sample would work too. </p>
  
  <p>Can I do this in Swift too? 
  I found nothing in the documentations.</p>
  
  <p>EDIT:</p>
  
  <p>andyvn22 wrote this will only happen in the playground and not in actual projects so I tried it.
  Just a simple command line tool with a function. I get the same error and it will not compile. If I move the call after the function definition it works fine.</p>
  
  <p><img src="https://i.stack.imgur.com/siKRY.png" alt="function"></p>