home | career | drupal | java | mac | mysql | perl | scala | uml | unix

Groovy example source code file (UseStaticInClosureBug.groovy)

This example Groovy source code file (UseStaticInClosureBug.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

groovytestcase, groovytestcase, usestaticinclosurebug, usestaticinclosurebug

The Groovy UseStaticInClosureBug.groovy source code

package groovy.bugs

/**
 * @version $Revision: 4996 $
 */
class UseStaticInClosureBug extends GroovyTestCase {

    static def stuff = [:]

    void testBug() {
        [1,2,3].each { stuff[it] = "dog" }

        assert stuff.size() == 3
        assert stuff[2] == "dog"
    }

    void testBug2() {
        doStatic()
    }

    static def doStatic() {
        [1,2,3].each { stuff[it] = "dog" }

        assert stuff.size() == 3
        assert stuff[2] == "dog"
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy UseStaticInClosureBug.groovy source code file:

new blog posts

 

Copyright 1998-2013 Alvin Alexander, alvinalexander.com
All Rights Reserved.