title: What is a slice in Swift?
body: <p>What is a slice in Swift and how does it differ from an array?</p>
  
  <p>From the documentation, the type signature of subscript(Range) is:</p>
  
  <pre><code>subscript(Range&lt;Int&gt;) -&gt; Slice&lt;T&gt;
  </code></pre>
  
  <p>Why not return another <code>Array&lt;T&gt;</code> rather than a <code>Slice&lt;T&gt;</code>?</p>
  
  <p>It looks like I can concatenate a slice with an array:</p>
  
  <pre><code>var list = ["hello", "world"]
  var slice: Array&lt;String&gt; = [] + list[0..list.count]
  </code></pre>
  
  <p>But this yields the error:</p>
  
  <blockquote>
    <p>could not find an overload for 'subscript' that accepts the supplied
    arguments</p>
  </blockquote>
  
  <pre><code>var list = ["hello", "world"]
  var slice: Array&lt;String&gt; = list[0..list.count]
  </code></pre>
  
  <p>What is a slice?</p>