UDA initialize a user defined type attribute field

Arjan arjan at ask.me.to
Tue Feb 18 16:00:50 PST 2014


On Tuesday, 18 February 2014 at 23:46:28 UTC, Adam D. Ruppe wrote:
> On Tuesday, 18 February 2014 at 23:43:56 UTC, Arjan wrote:
>> But how do I only set the MyAttrib.defaultvalue?
>
> You could do it by adding a constructor to MyAttrib that only 
> takes one string and fills it in that way.

But what happens than when only the first field 'name' is used in 
MyAttrib like this:

class OtherData
{
     @MyAttrib( "fancy name" )
     long id;
     ...
}

I guess the field MyAttrib.defaultvalue will be assigned the 
value "fancy name"?



More information about the Digitalmars-d-learn mailing list