title: fatal error: Can't form a Character from an empty String
body: <p>So I have function that strips off a trailing ", " (comma + space) at the end of a string and I'm getting the above error even though I'm ensuring that the string is not empty. The following code:</p>
  
  <pre><code>print("stripping trailing commas")
          for var detail in details {
              if detail.contains(",") {
  print(detail)
                  detail.remove(at: detail.endIndex)    // &lt;-- Removes last space
                  detail.remove(at: detail.endIndex)    // &lt;-- Removes last comma
              }
          }
  </code></pre>
  
  <p>...results int the following console output:</p>
  
  <pre><code>stripping trailing commas
  2016, 
  fatal error: Can't form a Character from an empty String
  </code></pre>
  
  <p>The first instance <code>detail.remove(at: detail.endIndex)</code> is being highlighted by the debugger, and while I can't be sure the space is present from the console message, I'm adding ", " at the end of each entry in a list so any string that actually contains a comma should not only have characters (as the console indicates) but it should have an extra two chars at the end that need to be stripped.</p>
  
  <p>Thanks in advance, for any help on <strong>what's causing the error</strong> and how to resolve?</p>