Skip to content

Instantly share code, notes, and snippets.

@walery
Created May 23, 2013 08:35
Show Gist options
  • Select an option

  • Save walery/5633535 to your computer and use it in GitHub Desktop.

Select an option

Save walery/5633535 to your computer and use it in GitHub Desktop.
List<Map> transformKeys(List<Map> lom, Map trans) {
lom.collect{map->
trans.collectEntries{ti->
[(ti.value): map[ti.key]]
}
}
}
assert transformKeys([[a: 1, b:2, c:3], [a: 1, x:2, y:3]], [a: 'alpha', b: 'beta']) == [[alpha:1, beta:2], [alpha:1, beta:null]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment