title: How to define an explicit casting operator in swift?
body: <p><strong>Background</strong></p>
  
  <p>I have a class that want to hide the implementation details.</p>
  
  <pre><code>class Foo
  {
    var i : Int
  }
  
  let f = Foo()
  </code></pre>
  
  <p><em>Is there a way to define an explicit cast operator so that gets invoked on <code>f as Int</code>?</em></p>
  
  <p>If not, is there a canonical method name that I should use like <code>asInt() -&gt; Int</code>?</p>