Enums in Processing 1.2.1?
Here is my sketch:
enum Foo { bar, baz }
void setup() { }
void draw() { }
This fails to compile:
Unrecognized type:46开发者_StackOverflow社区 (ENUM_DEF)
Am I doing something wrong, or are enums not supported?
Looks like they aren't supported unfortunately, but there are some workarounds. From the FAQ:
We currently only support Java 1.4 (and earlier) syntax. You cannot currently use 1.5 syntax in the Processing Development Environment. This means no generics, templates, enum, varargs, foreach, and the rest. If you want to use Java 1.5 (or later), take core.jar and develop your project with another Java IDE
If you're comfortable with Java, you can always base your project in Java and access the Processing code via traditional Java classes. The FAQ has some pointers on that too.
精彩评论