Converting Java code to D

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Apr 20 23:26:51 PDT 2015


On 2015-04-20 20:05, Steven Schveighoffer wrote:

> 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.

This is probably the best translation, depending on if the Java API 
needs to be retained or not. "label" is not included in this 
translation, assuming you can access that in Java.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list