pragma msg field name?

Ali Çehreli acehreli at yahoo.com
Tue Jun 27 04:56:19 UTC 2023


On 6/26/23 21:25, Chris Katko wrote:

 > How do I get just the field name?

I know .tupleof, which you can typeof() as well:

class myObject{
     int field1, field2, field3;

     static foreach(field; typeof(this).tupleof)
     {
         pragma(msg, field.stringof);
     }

     static foreach(MemberType; typeof(typeof(this).tupleof)) {
         pragma(msg, MemberType);
     }
}

The output:

field1
field2
field3
int
int
int

I had to consult what I wrote years ago:

   http://ddili.org/ders/d.en/tuples.html#ix_tuples..tupleof

Ali



More information about the Digitalmars-d-learn mailing list