On Tuesday, 1 March 2016 at 05:05:40 UTC, Jack Stouffer wrote:
In Python, I can do this:

    my_obj = Obj()
    string_from_func = func()
    setattr(my_obj, string_from_func, 100)

Say func() returns "member1" or "member2", the setattr would then set either one of those to 100.

Is there any equivalent in D?

Maybe if string_from_func can be computed at compile time.
Something like this:
http://dpaste.dzfl.pl/8bc21da1147a

?

Reply via email to