perl - Moose: How to get an array of objects? Traits? -
I have to realize that this is for beginners:
package bad; 'ARR' = & gt; (Is = & gt; 'RW', 'Arrayf [St]'); Package head; My $ Bad = Bad- & gt; New (arr = & gt; ["foo", "bar"]); Print $ bad- & gt; Arr- & gt; [0], "\ n"; Enter the symptoms. I'm underwhelmed by the symptoms API, though. Have I misunderstood something? Can I get something instead of this API? :
print $ bad-> Arr- & gt; Obtain (0), "\ n"; Description
Canonical Symptom Examples Review
Package Contents; Use mousse; 'Options' = & gt; (Symptom => ['array'], is => 'ro', isa = & gt; 'Arrayf [str]', default => sub [], handle => {all_options = & Gt; Include ', join_options = & gt;' push ', map_option => gt; map', filter_points = & gt; 'grep', find_option = & gt;, count_options = & gt; 'count', has_options = & Gt; 'count', has_no_options = & gt; 'is_empty', sorted_options = & gt; 'sort',},); No mousse; 1; Object has been announced, such as:.
My $ Options = $ Accessories- & gt; Get_option (1); I really do not like it that I want to get an array feature for 11 types of manually for a stratch class - for each operation that is for 'option'. One can do I How can I get (gracefully) with my $ option = $ accessories-> options: - & gt; (1),
Where are all methods implemented in a form-safe manner?
Then all the functions of each array are named in the same way ...
(I'm actually using the mouse, but most of the mouse is similar to the mousse)
I think the best way to get an API in that format is to select a new object You have to create and direct the methods directly in it. Something like this:
package content; Use mousse; Use the Stuff :: option; 'Options' = & gt; ('Is' = & gt; "ro", 'isa' = & gt; "staff :: option", 'default' => sub {content :: option-> new},); No mousse; 1; and then in Stuff / Options.pm :
Package Contents :: Options; Use mousse; '_options' = & gt; "Array" [St] ", 'Symptom' => [" Array "], 'Default' => sub {[ ]}, 'Handle' = & gt; [qw (element push mapp GP is included in the first count is_empty sort)]); No mousse; 1; This will allow the code to work for your example ( $ accessories-> option- & gt; receive (1) ).
Comments
Post a Comment