title: Swift array of protocol typed object
body: <p>I have next inheritance:</p>
  
  <pre><code>protocol P {
      var a : Int { get set }
  }
  
  class C : P {
      var a : Int
      ...
  }
  </code></pre>
  
  <p>And then i want to create generalised array and iterate through it with some action: </p>
  
  <pre><code>class Main {
      var array : Array&lt;Proto&gt;
      var inst : Proto
      ...
      func foo() {
          array.append(C(a:10))
          for obj in array {
              obj.a = 20      //Error: Cannot assign to the result of this expression
          }
  
          inst = C(a:10)
          inst.a = 20         //Works correctly
  
          for var i = 0; i &lt; arr.count; ++i {
              inst = arr[i]
              inst.a = 20     //No problem even here
          }
      }
  }
  </code></pre>
  
  <p>If i cast: (obj as C).a = 20 - then everything is OK. 
  Can someone explain this behaviour?</p>