Is there a way to grab the key of one map and replace the value of the other with its value?
def wild = [animal1:"pet3", animal2:"dog", animal3:"pig"]
def pet = [pet1:"hamster", pet2:"fish", pet3:"cat"]
if(pet.containsKey(wild.animal1)) {
//replace wild.animal1 with the value contained in pet3 for example
//so wild.animal1 would equal "cat"
} else {
//dont change value
}
So basically I'm wondering if I am able to find a key based on a value in the map wild and replacing the value with the value of the key in the map pet.
Is there a simple way of going about this?