Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.5.7
-
Fix Version/s: 1.6.1, 1.5.8, 1.7-beta-1
-
Component/s: None
-
Labels:None
-
Environment:XP, cygwin, JRE 1.6.0
-
Number of attachments :
Description
A call method on an enum can be used within a for loop, but not otherwise. This is kind of odd, and it might be better to disable the for loop behavior if it's not reasonable to fix in general.
enum Foo {
A({ println("A") }),
B({ println("B") })
Foo(Closure c) {
call = c
}
final Closure call
}
// works
for (f in Foo) {
f()
}
// works
Foo.A.call()
// doesn't work
Foo.A()
// doesn't work
a=Foo.A
a()
I don't think if
Foo.A() and
a=Foo.A
a()
are even supposed to work as per groovy syntax.
If call is a member of enum Foo of type Closure as shown in the JIRA example, then what is supposed to work is:
Foo.A.call() and Foo.A.call.call() (same as f =
{..}and calling it as f() and f.call()), and
a=Foo.A
a.call() and a.call.call()