title: How to offset a Range<T> in Swift?
body: <p>Imagine we have an arbitrary <code>Range&lt;T&gt;</code> and we want to create a new range with <code>startIndex</code> and <code>endIndex</code> advanced by 50 units.</p>
  
  <p>My first thought was to do this:</p>
  
  <pre><code>let startIndex = advance(range.startIndex, 50)
  let endIndex = advance(range.endIndex, 50)
  var newRange = startIndex..&lt;endIndex
  </code></pre>
  
  <p>But this gives "fatal error: can not increment endIndex". (Well, it does with <code>Range&lt;String.Index&gt;</code>. I haven't tried it with other generic parameters.) I've tried quite a few permutations of this, including assigning <code>range.startIndex</code> and <code>range.endIndex</code> to new variables, etc. Nothing works.</p>
  
  <p>Let me stress that I'm looking for a solution that works with <em>any</em> <code>T</code>. GoZoner gave an answer below that I haven't tried with <code>Int</code>, but I wouldn't be surprised if it worked. However, no permutation of it I tried will work when <code>T</code> is <code>String.Index</code></p>
  
  <p>So, how can I do this?</p>