Created
November 14, 2016 11:33
-
-
Save papapana/6ee2a5ca2bec5cafed3d4fb54f566671 to your computer and use it in GitHub Desktop.
Check if key exists in map in Groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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