title: swift: Assign function type to variable
body: <pre><code>    struct System {
          var method: (() -&gt; ())?
          var curMethod: Int
  
          init() {
              method = nil
  curMethod = 0
          }
  
          mutating func method1() {
              curMethod = 1
          }
  
          mutating func method2() {
              curMethod = 2
          }
      }
  
      var sys = System()
      sys.method = System.method1
      sys.method!()
  </code></pre>
  
  <p>I get an error cannot assign value of type <code>(inout System) -&gt; () -&gt; ()' to type '(() -&gt; ())?</code>. What am I doing wrong?</p>