On 4/20/15 11:28 AM, Mike James wrote:
Here is a fragment of Java code from an SWT program...

public enum LineStyle {
     NONE("None"),
     SOLID("Solid"),
     DASH("Dash"),
     DOT("Dot"),
     DASHDOT("Dash Dot"),
     DASHDOTDOT("Dash Dot Dot");

     public final String label;

     private LineStyle(String label) {
         this.label = label;
     }
}

What would be the best ('canonical') way of translating it to D?

enum LineStyle : string {
   NONE = "None",
   SOLID = "Solid",
   ... // etc
}

Used like this:

funcThatTakesString(LineStyle.NONE);

LineStyle ls = LineStyle.SOLID;

funcThatTakesLineStyle(ls);

I'm not a Java programmer, and my time with Java was before enums. But this is how I would do it.

-Steve

Reply via email to