title: What is the correct way to get a subarray in Scala?
body: <p>I am trying to get a subarray in scala, and I am a little confused on what the proper way of doing it is.  What I would like the most would be something like how you can do it in python:</p>
  
  <pre><code>x = [3, 2, 1]
  x[0:2]
  </code></pre>
  
  <p>but I am fairly certain you cannot do this.</p>
  
  <p>The most obvious way to do it would be to use the Java Arrays util library.</p>
  
  <pre><code>import java.util.Arrays
  val start = Array(1, 2, 3)
  Arrays.copyOfRange(start, 0, 2)
  </code></pre>
  
  <p>But it always makes me feel a little dirty to use Java libraries in Scala.  The most "scalaic" way I found to do it would be</p>
  
  <pre><code>def main(args: List[String]) {
      val start = Array(1, 2, 3)
      arrayCopy(start, 0, 2)
  }
  def arrayCopy[A](arr: Array[A], start: Int, end: Int)(implicit manifest: Manifest[A]): Array[A] = {
      val ret = new Array(end - start)
      Array.copy(arr, start, ret, 0, end - start)
      ret
  }
  </code></pre>
  
  <p>but is there a better way?</p>