title: Groovy get all elements in a list under certain index
body: <p>I want to collect all the elements in a specific array list under a specific index. Let's say I have this list:</p>
  
  <pre><code>def names = ["David", "Arthur", "Tommy", "Jacob"]
  </code></pre>
  
  <p>I want to print all the names under the index of 2, which in this case, will print "David, Arthur"</p>
  
  <p>Now I can use a for loop quite easily with that or even groovy's <code>eachWithIndex()</code>. The problem is I don't want to run all over the elements because that's not efficient. Rather than that, I want to run until a specific point.</p>
  
  <p>Is there any method in groovy which does that , because I didn't find one.</p>
  
  <p>Thanks in advance!</p>