按列表过滤Groovy地图 [英] Filtering Groovy map by a list
本文介绍了按列表过滤Groovy地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在groovy中,有一种简单的方法可以通过列表过滤地图的索引.
In groovy is there a simple way to filter a map`s indexes by a list.
produce_map = ["grapes":"fruit","apple":"fruit","tomato":"vegetable","peas:"vegetable"]
green_produce_list = ["grapes","apples",'peas']
<magic code>
//desired result
filterd_map = ['apple':'fruit','grapes':'fruit','peas':'vegetable']
推荐答案
查看全文