Skip to content

Instantly share code, notes, and snippets.

@bobbywarner
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save bobbywarner/542df1eb6668c5651336 to your computer and use it in GitHub Desktop.

Select an option

Save bobbywarner/542df1eb6668c5651336 to your computer and use it in GitHub Desktop.
Groovy SubMap
Map foo = [1: "one", 2: "two"]
Map bar = [1: "one"]
assert [1: "one"] == foo.subMap( bar.collect { it.key })
Map foo2 = [1: "one", 2: "two"]
Map bar2 = [1: "one", 2: "two", 3: "three"]
assert [1:"one", 2:"two"] == foo2.subMap( bar2.collect { it.key })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment