Converting Java code to D
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Apr 20 10:28:26 PDT 2015
On Monday, 20 April 2015 at 17:24:30 UTC, bearophile wrote:
> John Colvin:
>
>> struct LineStyle
>> {
>> enum NONE = "None";
>> enum SOLID = "Solid";
>> enum DASH = "Dash";
>> enum DOT = "Dot";
>> enum DASHDOT = "Dash Dot";
>> enum DASHDOTDOT = "Dash Dot Dot";
>>
>> string label;
>>
>> private this(string label)
>> {
>> this.label = label;
>> }
>> }
>
> The constructor doesn't look very useful.
>
> Perhaps a named enum is safer.
>
> Bye,
> bearophile
True, the constructor doesn't really add anything here.
To be honest, the combination of enumeration and runtime
variables in the Java code seems like a rubbish design, but
perhaps there's a good reason for it that I'm not aware of.
More information about the Digitalmars-d-learn
mailing list