Given a class like: our %attrs = (age=>1,wgt=>2); class foo { has $.age = rw;}
method a { for %attrs.kv -> $k, $v { my $aval = self."$k"(); # supposed to work for a method name say "attr { $k } has value '{ $aval }'"; } } Question: 1. How can I indirectly refer to the attributes in a method? The above doesn't work (with or without the '()'). 2. Do I have to write a custom accessor to do so? Thanks. Best regards, -Tom