title: How can I remove all nil elements in a Swift array?
body: <p>Basic way doesn't work.</p>
  
  <pre><code>for index in 0 ..&lt; list.count {
      if list[index] == nil {
          list.removeAtIndex(index) //this will cause array index out of range
      }
  }
  </code></pre>