-4

I create objects from the class called Company. How can I get the very first created object?

Andrew Lygin
  • 6,077
  • 1
  • 32
  • 37
user6731260
  • 105
  • 1
  • 1
  • 4
  • 6
    possible duplicate of http://stackoverflow.com/questions/4839834/get-the-first-element-of-a-list-idiomatically-in-groovy – ABC Aug 24 '16 at 10:35

1 Answers1

0

If Company is a persistent object (an instance of a domain class), this should work

def firstCompany = Company.first()
Dónal
  • 185,044
  • 174
  • 569
  • 824