> Those are great additions. You need a duplicate_deep and a
> replicate_deep, though. Right now, any obejcts stored in the array
will be
> references in the new array. A _deep method would make copies of those
> too, recursively caling Array.duplicate, or Object.duplicate. ;-)

I'm not sure this is an issue, and here's why.  An Array is an
enumerable hash of references.  If I'm duplicating the Array, I'm not
duplicating the references, I'm duplicating the container of the
references.  Array.duplicate duplicates the Array.

What you're describing is not really a method of Array, and blurs the
line between an Array and the contents of an Array.  Plus, I don't see
how what you're describing could really be useful and it seems like a
dangerous notion fraught with potential memory waste/leaks.  :)

And, you can actually write it yourself easily enough with each or
collect.

newArray = oldArray.duplicate();
function dupeObj(o) {
        // newObj = duplicate o
        return newObj;
}
newArray.collect(dupeObj);

Tada!

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to