title: swift - using replaceRange() to change certain occurrences in a string
body: <p>Say I have a string, and I want to change the first "a" in that string to an "e" in order to get the correct spelling.</p>
  
  <pre><code>let animal = "elaphant"
  </code></pre>
  
  <p>Using <code>stringByReplacingOccurrencesOfString()</code> will change every "a" in that string to an "e", returning:</p>
  
  <pre><code>elephent
  </code></pre>
  
  <p>I am trying to get the index of the first "a" and then replacing it using <code>replaceRange()</code>, like so:</p>
  
  <pre><code>let index = animal.characters.indexOf("a")
  let nextIndex = animal.startIndex.distanceTo(index!)
  animal = animal.replaceRange(animal.startIndex.advancedBy(nextIndex)..&lt;animal.startIndex.advancedBy(1), with: "e")
  </code></pre>
  
  <p>However, this code gives me the following error:</p>
  
  <pre><code>Cannot assign value of type '()' to type 'String'
  </code></pre>
  
  <p>I have been trying to find a way to convert nextIndex into an <code>Int</code>, but I feel like I've got this whole method wrong. Help?</p>