title: Swift - create a fixed length array enforced at compile time
body: <p>I want to enforce (compile time) array with 5 elements of a particular type</p>
  
  <p>I couldn't find a solution so resorted to a workaround by creating a tuple </p>
  
  <p><strong>(This is abusive I know)</strong> </p>
  
  <pre><code>typealias FiveElementArray = (MyType,MyType,MyType,MyType,MyType) // mock array by using typed tuple
  </code></pre>
  
  <p>It works for my needs - until I need to access an element by index at runtime.</p>
  
  <p>For instance:</p>
  
  <pre><code>var DB = FiveElementArray // the tuple of 5 elements
  
  tableView(tableView : UITableView,cellForRowAtIndexPath:indexPath) -&gt; UITableViewCell {
  // would like to populate with the value at index
  DB[indexpath.row] // no such syntax for tuples
  
  }
  </code></pre>
  
  <p>So how can I use a proper swift Array with statically typed length</p>