title: Swift3 & Xcode8: ’subscript' is unavailable: cannot subscript String with a CountableClosedRange<Int>,
body: <p><strong>Error 1</strong>:
  When I am trying get the <code>stringValue</code> from Metadata shows above error in <code>Swift3</code>:</p>
  
  <pre><code>let myMetadata: AVMetadataMachineReadableCodeObject = metadataObjects[0] as! AVMetadataMachineReadableCodeObject
  
  // take out the system and check-digits
  let myBarcode = myMetadata.stringValue[1...11] //error 
  </code></pre>
  
  <p><strong>Error 2:</strong>
  In extensions of String I write these to get <code>right(x)</code> and <code>left(x)</code> function to get substring:</p>
  
  <pre><code>extension String {
  
      // length of string
      var length: Int {
          return self.characters.count
      }
  
      //  right(x) and left(x) function to get substring
      func right(_ i: Int) -&gt; String?
      {
          return self[self.length-i ... self.length-1 ] //error  
      }
  
      func left(_ i: Int) -&gt; String?
      {
          return self[0 ... i-1] //error     
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/yfjpl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yfjpl.png" alt="enter image description here"></a></p>