title: Cannot invoke initializer for type 'Range<_>' with an argument list of type '(Range<String.Index>)'
body: <blockquote>
    <p>Since Xcode 10 I receive an error message <code>Cannot invoke initializer for type 'Range&lt;_&gt;' with an argument list of type '(Range&lt;String.Index&gt;)'</code> at the return line in the code below, which is an extension used to get a substring when needed.</p>
  </blockquote>
  
  <p>I have found another good answer given by Martin R at <a href="https://stackoverflow.com/questions/50714543/cannot-invoke-initializer-for-type-rangestring-index-with-an-argument-list-o">Cannot invoke initializer for type &#39;Range&lt;String.Index&gt;&#39; with an argument list of type &#39;(Range&lt;String.Index&gt;)&#39;</a>, but didn't find a way yet to fix my problem.</p>
  
  <pre><code>extension String {
      subscript (i: Int) -&gt; Character { return self[index(startIndex, offsetBy: i)] }
      subscript (i: Int) -&gt; String { return String(self[i] as Character) }
          subscript (r: Range&lt;Int&gt;) -&gt; String {
          let start = index(startIndex, offsetBy: r.lowerBound)
          let end = index(startIndex, offsetBy: r.upperBound)
  
          return String(self[Range(start ..&lt; end)])
      }
  }
  </code></pre>