Skip to content

Instantly share code, notes, and snippets.

@arosenb2
Last active May 24, 2016 15:20
Show Gist options
  • Save arosenb2/ddef0a6584f060133962feaef4732095 to your computer and use it in GitHub Desktop.
Save arosenb2/ddef0a6584f060133962feaef4732095 to your computer and use it in GitHub Desktop.
Test for Null or Boolean Map Attribute
def foo = null
def bar = [active: false]
def foobar = [active: true]
println "Long hand version"
println "--------"
println "Foo: ${! foo || ! foo.active}"
println "Bar: ${! bar || ! bar.active}"
println "Foobar: ${! foobar || ! foobar.active}"
println "\nShort hand version"
println "--------"
println "Foo: ${! foo?.active}"
println "Bar: ${! bar?.active}"
println "Foobar: ${! foobar?.active}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment