|
Groovy example source code file (ClosureReturnWithoutReturnStatementTest.groovy)
The Groovy ClosureReturnWithoutReturnStatementTest.groovy source code
package groovy
class ClosureReturnWithoutReturnStatementTest extends GroovyTestCase {
void testReturnValues() {
def block = {x-> x > 5}
def value = block.call(10)
assert value
value = block.call(3)
assert value == false
}
void testReturnValueUsingFunction() {
def block = {x-> someFunction(x) }
def value = block.call(10)
assert value
value = block.call(3)
assert value == false
}
def someFunction(x) {
x > 5
}
}
Other Groovy examples (source code examples)Here is a short list of links related to this Groovy ClosureReturnWithoutReturnStatementTest.groovy source code file: |
Other websites by Alvin Alexander:
Life/living in Alaska (OneMansAlaska.com)
How I Sold My Business (HowISoldMyBusiness.com)
Copyright 1998-2011 Alvin Alexander, devdaily.com
All Rights Reserved.