Last active
May 24, 2016 15:20
-
-
Save arosenb2/ddef0a6584f060133962feaef4732095 to your computer and use it in GitHub Desktop.
Test for Null or Boolean Map Attribute
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
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