title: Accessing function defined within function in swift
body: <p>Say I have a class <strong>NamedShape</strong> defined like this:</p>
  
  <pre><code>class NamedShape {
      var numberOfSides: Int = 0
      var name: String
  
      init(name: String) {
        self.name = name
      }
  
      func simpleDescription() -&gt; String {
         return "A shape with \(numberOfSides) sides."
      }
  
      func containerFunc() -&gt; Void{
          println("strange world")
  
          func subFunc() -&gt; String {
              return "sub function returns string"
          }
  
          println(subFunc())
  
      }
  }
  </code></pre>
  
  <p>I can initialize it like this:</p>
  
  <pre><code>let someNamedShape = NamedShape(name:"polynomial")
  </code></pre>
  
  <p>And invoke some method like this:</p>
  
  <pre><code>someNamedShape.containerFunc()
  </code></pre>
  
  <p>Now how can I invoke method <strong>subFunc</strong> within <strong>containerFunc</strong> on its object?</p>
  
  <p>Compiler complains while trying this: </p>
  
  <pre><code>someNamedShape.containerFunc().subFunc()
  </code></pre>