title: closures and withUnsafeBufferPointer() in swift
body: <p>I'm just trying to get my head around closures in swift.</p>
  
  <p>I want to use the withUnsafeBufferPointer method of an array.  In the simplest form, I can do something like this successfully:</p>
  
  <pre><code>var aa:[UInt8] = [1,2,3,4,5,6,7,8]
  var bb = aa.withUnsafeBufferPointer({$0.baseAddress})
  </code></pre>
  
  <p>I can also do this:</p>
  
  <pre><code>var bb = aa.withUnsafeBufferPointer({pointerVal in pointerVal.baseAddress})
  </code></pre>
  
  <p>however, I cannot do this without generating an error in xcode:</p>
  
  <pre><code>var bb = aa.withUnsafeBufferPointer({pointerVal in return pointerVal.baseAddress})
  
  "Cannot convert the expression's type '((ST5)-&gt;(ST5)-&gt;ST4)-&gt;((ST5)-&gt;ST4)-&gt;ST4' to type 'R' 
  </code></pre>
  
  <p>In the first two assignments, the <code>return</code> statement is implied.  If I put it in explicitly, things fail.  I cannot reconcile this with the documentation from Apple. (see chapter on closures in The Swift Programming Language).  I want to put a more complex closure into this, which requires a return statement.  What do I have to do in order to accomplish that?</p>