title: Generic parameter 'Self' could not be inferred (swift 4)
body: <p>I want to make a substring extension for string , I tried below 2 ways but unsuccessful: </p>
  
  <pre><code>extension String
  {
      func substringToFirstChar(of char: Character) -&gt; String
      {
          let pos = self.range(of: String(char))
          let subString = self[..&lt;pos?.lowerBound]   
          return String(subString)
      }
  }
  </code></pre>
  
  <p>or </p>
  
  <pre><code>extension String
  {
      func substringToFirstChar(of char: Character) -&gt; String
      {
          let pos = self.index(of: char)
          let subString = self[..&lt;pos]
          return String(subString)
      }
  }
  </code></pre>
  
  <blockquote>
    <p>xcode prompt error:  <strong>Generic parameter 'Self' could not be inferred</strong>  at the "<strong>let subString = self[..</strong>" line.</p>
  </blockquote>
  
  <p>How to do that ?</p>