0

I have two lists:

 def courseList  = PublicTraining.executeQuery(
     "SELECT t.course.id, t.course.name from PublicTraining AS t")
 def cityList  = PublicTraining.executeQuery(
     "SELECT t.venue.city.id, t.venue.city.name from PublicTraining AS t")

and:

courseList  = [[1, weblogic], [2, ajax]]
cityList   = [[1, City1], [2, City2]]

How can I create a Map which looks like this?

resultMap = ['Course':[['1', 'weblogic'],['2', 'ajax']], 'City':[['1','City1'],
    ['2','City2']] ]
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
monda
  • 3,809
  • 15
  • 60
  • 84
  • 1
    possible duplicate of [shortcut for creating a Map from a List in groovy?](http://stackoverflow.com/questions/18538/shortcut-for-creating-a-map-from-a-list-in-groovy) – Michael Easter Oct 01 '13 at 12:27
  • 7
    If you have the two list why don't you just create the map `resultMap = ['Course' : courseList, 'City' : cityList]` I think, I'm missing something on the question..... – jjchiw Oct 01 '13 at 12:34
  • or in one row resultMap = [ Course: PublicTraining.executeQuery( "SELECT t.course.id, t.course.name from PublicTraining AS t"), City: PublicTraining.executeQuery( "SELECT t.venue.city.id, t.venue.city.name from PublicTraining AS t") ] – Fabiano Taioli Oct 01 '13 at 13:29

0 Answers0