Reputation: 3401
If i have this snippet from my action
for (c in AuthorList){
def bookCount = Book.countByName(c)
}
How do i make my bookCount
into a list
Upvotes: 0
Views: 48
Reputation: 50275
for
loop is not required at all. ;)
authorList.collect { Book.countByName( it ) }
should give the list you are looking for.
Upvotes: 1
Reputation: 2370
Try to use <<
def list = []
for (c in AuthorList){
def bookCount = Book.countByName(c)
list << bookCount
}
Upvotes: 0