Last active
October 23, 2020 16:23
-
-
Save ciis0/5de43b6138ab536de28b97ee4bc71b55 to your computer and use it in GitHub Desktop.
groovy string truth
This file contains 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
[null, "false", "true", "", "foo", "null", "0", "1", "2", "-1"].collectEntries { str -> | |
if(!str){ | |
[str, "empty"] | |
} else { | |
[str,"non-empty"] | |
} | |
} | |
// {null=empty, false=non-empty, true=non-empty, =empty, foo=non-empty, null=non-empty, | |
// 0=non-empty, 1=non-empty, 2=non-empty, -1=non-empty} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment