real simple manifest constant question probably regret asking...

rikki cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 15 20:29:25 PDT 2017


On 16/03/2017 4:27 PM, WhatMeForget wrote:
>
> One of my D books says: "an enum declared without any braces is called a
> manifest constant." The example shows,
>
> enum string author = "Mike Parker";
>
> Is this equivalent to
> const string author = "Mike Parker";
> or
> immutable string author = "Mike Parker";
>
> I guess what I'm asking is does enum give you some advantages over say
> non-enum constants?
>
> Thanks.

No.

An enum is an enum, that variation of the syntax just has a special name 
that's all.

Keep in mind the typed aspect doesn't have an affect other than forcing 
the value to it.

enum Foo : string {
	Author = "Mike Parker"
}



More information about the Digitalmars-d-learn mailing list