Reputation: 1164
I have an array of elements and wanted to create a map out of it
def vegetable = ['carrot', 'salad']
def fruit = ['orange', 'apple']
def all_food = group_a + group_b
def my_map = [:]
for(item in all_food) {
my_map.put(item, "edible")
}
any thought how to create it inline?
def my_map = all_food.each{it, "edible"}
or smth similar ?
Upvotes: 1
Views: 62