Friday, October 4, 2013

Groovy: Get First n Elements from a List

A Groovy snippet to get first n elements from a list.
def a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
a.take(3) // [1, 2, 3]