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

Reply via email to