It saves our time to write tedious get/set methods.
But it seems to me only handy for scalar data members, won't fit for array/hash data members开发者_StackOverflow,right?
For most Class::Accessor
variants, including Class::Accessor::Fast
, the underlying structure representing the objects are blessed hash references.
Hashes can only store scalars as their values.
However, that doesn't mean you can't store a list of things, a hash of things, or whatever else in your object. Merely take a reference to whatever non-scalar structure you want to store.
All references are scalars, and a hash will be able to store them just fine, no matter if you use direct object access, accessors generated by some Class::Accessor
variant, Moose
, or anything else that helps you in building your objects upon hash references.
精彩评论