Loop through Map in Groovy?

后端 未结 4 407
余生分开走
余生分开走 2021-01-30 02:11

I have a very simple task I am trying to do in Groovy but cannot seem to get it to work. I am just trying to loop through a map object in groovy and print out the key and value

4条回答
  •  一向
    一向 (楼主)
    2021-01-30 02:19

    Another option:

    def map = ['a':1, 'b':2, 'c':3]
    map.each{
      println it.key +" "+ it.value
    }
    

提交回复
热议问题