Skip to content

Instantly share code, notes, and snippets.

@ciis0
Last active October 23, 2020 16:23
Show Gist options
  • Save ciis0/5de43b6138ab536de28b97ee4bc71b55 to your computer and use it in GitHub Desktop.
Save ciis0/5de43b6138ab536de28b97ee4bc71b55 to your computer and use it in GitHub Desktop.
groovy string truth
[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