How to use annotation get key name?

Adam D. Ruppe destructionator at gmail.com
Tue Mar 27 16:19:30 UTC 2018


On Tuesday, 27 March 2018 at 15:38:48 UTC, Brian wrote:
> but you don't understand my means, I want have keys with 
> multiple indeterminate names.

You can pass an associative array (or better yet, a struct 
containing one) as a UDA and then use the regular loop over its 
keys and values.

struct Table { string[string] keys_and_values; }

@Table(["name1": "users", "name2" : "users111"])
void foo() {}


D's UDAs are just a value attached to the name, so all normal 
rules of types apply.


More information about the Digitalmars-d-learn mailing list