|
Groovy example source code file (ClosureInStaticMethodTest.groovy)
The Groovy ClosureInStaticMethodTest.groovy source codepackage groovy /** * @author <a href="mailto:james@coredevelopers.net">James Strachan * @version $Revision: 4996 $ */ class ClosureInStaticMethodTest extends GroovyTestCase { void testClosureInStaticMethod() { def closure = closureInStaticMethod() assertClosure(closure) } void testMethodClosureInStaticMethod() { def closure = methodClosureInStaticMethod() assertClosure(closure) } static def closureInStaticMethod() { return { println(it) } } static def methodClosureInStaticMethod() { System.out.&println } static def assertClosure(Closure block) { assert block != null block.call("hello!") } void testClosureInStaticMethodCallingStaticMethod() { assert doThing(1) == 10 assert this.doThing(1) == 10 assert ClosureInStaticMethodTest.doThing(1) == 10 } static doThing(count) { def ret = count if (count > 2) return ret count.times { ret += doThing(count+it+1) } return ret } } Other Groovy examples (source code examples)Here is a short list of links related to this Groovy ClosureInStaticMethodTest.groovy source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.