Member Access Based On A Runtime String

Jack Stouffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 29 21:05:40 PST 2016


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?


More information about the Digitalmars-d-learn mailing list