arrays of object in OO perlby IL_MARO (Initiate)
|on Nov 19, 2008 at 04:39 UTC||Need Help??|
IL_MARO has asked for the
wisdom of the Perl Monks concerning the following question:
here is my problem:
You have a class, say, called Animal. Animal has a feature called DNA, and DNA is an array. Example:
Now, imagine you want to create another class, say, called Population. And you want a bag of Animals, like:
As you can see, the method init simply pushes 5 not empty Animals into a Population object.
The problem is that I'm not able to access them! What I should do if I want, say, set the DNA of a specific Animal of the Population?
And what if want to get or set a specific value of a specific slot of the DNA of an Animal...? I lack the knowledge I need. I tryied in many ways. Just an example, if I want to get the DNA of the Animal in the first slot:
But of course it's not working.
I can't get what I want...