Problems? Is your data what you think it is? | |
PerlMonks |
[raku] what accessors are actually autogenerated for @.array attributes?by tomgracey (Scribe) |
on May 06, 2021 at 14:22 UTC ( [id://11132158]=perlquestion: print w/replies, xml ) | Need Help?? |
tomgracey has asked for the wisdom of the Perl Monks concerning the following question: Hello I have another (absurdly basic) Raku question. Consider the following:
This doesn't work. I get:
The "1 argument" it appears to be expecting seems to be self. ie it seems specifying @.scales creates only the get accessor. Is this correct? Do we have to create our own set accessors for array-type attributes? I may be looking in the wrong place, but I could not find any documentation on exactly what accessors are autogenerated - the docs seem to just say "specify the period twigil to have accessors autogenerated". Part of my problem may be that I am not familiar enough with the various inspection methods. Possibly there is a way to see exactly what methods are being created. For example the ^methods meta-method does return a list of methods, but without any accompanying information - e.g is it a multimethod etc. So scales would come up in the list if $fish.^methods is called, but it would seem only once regardless if there is a setter. Is anyone aware of a way of getting a more detailed list? Sorry again for the basic question, but sometimes it seems better to get some direct feedback rather than trawling endlessly in the hope of finding examples. (I looked through vast swathes of code for an example of setting an array after the object has been created and didn't happen on any at all. Plenty of setting it via new of course. Not sure if I was just unlucky.) Anyway thanks in advance for your help
Back to
Seekers of Perl Wisdom
|
|