We could already use the head()
and tail()
methods on Collection
objects in Groovy, but in Groovy 1.7.3 we can use them on Object arrays as well.
String[] stringArray = ['Groovy', 'Grails', 'Spock'] assert 'Groovy' == stringArray.head() assert ['Grails', 'Spock'] == stringArray.tail() assert 'Groovy' == stringArray.first() assert 'Spock' == stringArray.last()