Skip to content

Instantly share code, notes, and snippets.

@papapana
Created November 14, 2016 11:33
Show Gist options
  • Save papapana/6ee2a5ca2bec5cafed3d4fb54f566671 to your computer and use it in GitHub Desktop.
Save papapana/6ee2a5ca2bec5cafed3d4fb54f566671 to your computer and use it in GitHub Desktop.
Check if key exists in map in Groovy
filter = [:]
key = 'example'
if (filter.containsKey(key)) {
// do if the key is contained
// e.g. filter[key] << 'hello_again'
} else {
// do if key is not contained
// e.g. filter[key] = ['hello']
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment