Details
Description
I have the following code which doesn't work:
import static Constants.* class Constants { static final String NAME = "name" } def map = [:] if(!map[NAME]) { // <------ this succeeds... map[NAME] = "erik" // <------ this fails! } println map
However, the following does work:
import static Constants.* class Constants { public static final String NAME = "name" // <---- mind the public! } def map = [:] if(!map[NAME]) { // <------ this succeeds... map[NAME] = "erik" // <------ and this also succeeds... }
This can also be solved by prefixing the NAME constant with the class (Constants.NAME)