Skip to content

Instantly share code, notes, and snippets.

@danieldbower
Last active August 29, 2015 13:59
Show Gist options
  • Save danieldbower/10732400 to your computer and use it in GitHub Desktop.
Save danieldbower/10732400 to your computer and use it in GitHub Desktop.
Groovy Truth Examples
Map vals = ['Zero':0, 'Negative decimal':-0.01, 'Negative decimal':-0.05, 'Negative whole number':-1,
'Negative decimal':-1.5, 'One':1, 'Positive decimal':0.01, 'Positive decimal':0.05,
'Positive decimal':1.5, 'Empty string':'', 'Empty list':[], 'Empty hash':[:],
'Lower character':'a', 'Upper character':'A', 'Null':null
]
vals.each{ k, v ->
println (v ? "$k ( $v ) is true" : "$k ( $v ) is false")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment