On May 03, 2006, at 15:17 UTC, Jason Essington wrote: > > Well, you can't make this method general, since it needs to match > > the specific type of the array it's going to operate on. The > > reasons for this take a little thought to see, but they are quite > > legitimate. > > BAH! I forgot, RB doesn't have a proper Object that is the base of > all objects :-(
No, that has nothing to do with it. You can declare an array of type Object. But that simply doesn't help. Let's use the classic "fruits" hierarchy to see why: Suppose you have a method that can operate on an array of Fruits. Perhaps all fruit objects have a Sweetness property, and this method sorts fruits by their sweetness: Sub SortBySweetness( fruits() as Fruit ) That's fine, but now suppose you have elsewhere in your code an array declared as: Dim apples() as Apple An Apple is a Fruit, so you can pass this to your SortBySweetness method, right? Wrong. The SortBySweetness code knows only that that its array is defined to contain fruits, so it would be perfectly valid for it to do something like: fruits.Append New Orange Now, if you could pass your apples array in, you'd end up with an array declared to contain only Apples, but actually containing an Orange. The result would be a crash. So you can see, just because an Apple IsA Fruit, does NOT mean that an array of Apples IsA array of Fruits. That's why you can't make a generic CloneArray method that would work on any array of Cloneable objects, and is probably why RB doesn't contain such functionality. It has to be written for the specific type care about. (It's also why most of the methods in my open-source ArrayUtils module don't operate on object arrays, even when it might naively seem like they could.) HTH, - Joe -- Joe Strout -- [EMAIL PROTECTED] Available for custom REALbasic programming or instruction. _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
