in reply to Re: Using ArrayRef data members in Moose
in thread Using ArrayRef data members in Moose
Well, whaddaya know...
Whack! “Doh!!”I figured it out!
It seems that the magic is this: this definition adds new methods, to the object, not the array attribute, which have the “magical effect” of doing the appropriate operation to the appropriate attribute... automagically knowing both what the attribute is, and what to do with it.
What was throwing me off, for the longest time, was this incorrect code:
$n = $object->items->num_items(); ##INCORRECTwhich was giving me the very mysterious error:
# died: Can't call method "num_items" on unblessed reference...
Which is incorrect because the method is attached to the object. Oh... I get it... Gee, it's even seriously cool...
Therefore, this works:
$n = $object->num_items(); ##CORRECT
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Using ArrayRef data members in Moose
by Anonymous Monk on Feb 18, 2011 at 17:49 UTC | |
|
Re^3: Using ArrayRef data members in Moose
by Anonymous Monk on Feb 18, 2011 at 17:49 UTC | |
by stvn (Monsignor) on Feb 19, 2011 at 21:23 UTC |