title: Cannot increment beyond endIndex
body: <p>I'm looking for the "Swift 3" way of handling an error where I try to increment the position of a string to an out of bounds index. I have an extension that looks like the following:</p>
  
  <pre><code>extension String {
    func substring(from: Int) -&gt; String {
          let fromIndex = index(from: from)
          return substring(from: fromIndex)
    }
  }
  </code></pre>
  
  <p>In implementation code, I have a loop which periodically takes chunks of a string and moves the index further in the string. My problem is I'm not sure what the Swift 3 way is of handling "End of String, do not proceed if we've reached the end"</p>
  
  <p>Implementation code is something as trivial as this:</p>
  
  <pre><code>myStr = myStr.substring(from: pos + 1)
  </code></pre>
  
  <p>if <code>pos + 1</code> is the end of the string, it shouldn't error out, but should instead just exit/return from my loop. What's the best way of doing that?</p>