I use addAll() all the time... Mark
On Sat, Feb 14, 2009 at 12:45 PM, Henry <[email protected]> wrote: > > Just earlier today I wanted to write a function to combine two array > into one array. So I was thinking, maybe I should write an > > void ArrayConcat(array1, array2) // that appends items in array2 to > the end of array1 > > Then after the code ready, I couldn't figure out how come it didn't > work... then PASS BY VALUE hits me in the head! ouch. > > It'd be nice if ArrayList.addAll() works on CF's array all time time, > but it does not. I guess that's why no body calls the underlying java > method... > > > Henry Ho > > > On Feb 13, 4:43 pm, Mark Mandel <[email protected]> wrote: > > Because you have no granular control over it. > > > > Currently, the only way to force arrays to pass by reference, you have to > > create a Java List implementation, like Vector, or ArrayList. > > > > In (almost?) every other programming language, everything is passed by > > reference, unless you specify it otherwise. > > > > That way, if you want a new copy of an array you can say: > > > > newarray = myarray.clone(); > > > > and be explicit with your needs. > > > > Pass by value of arrays in CF drives me nuts, but it was an old, old, old > > decision, and it's not going to change. > > > > Mark > > > > On Sat, Feb 14, 2009 at 11:02 AM, Judah McAuley <[email protected] > >wrote: > > > > > > > > > > > > > I'm curious about your reasoning behind that feeling. Passing objects > > > by value makes perfect sense to me. If I want a reference to myarray > > > than why don't I just call myarray? If I say thisotherarray = myarray > > > then I'm copying myarray over because I'm presumably doing to do > > > something else with it. If I want to do something with myarray then I > > > should act upon myarray, not upon a reference to it. > > > > > Judah > > > > > On Fri, Feb 13, 2009 at 2:05 PM, Peter Bell <[email protected]> > > > wrote: > > > > > > I think passing arrays by value in ColdFusion only truly makes sense > > > > to someone who's off their meds, but because it is the way things > > > > work, it will continue to be the way things work to avoid breaking > > > > legacy code. > > > > > > Best Wishes, > > > > Peter > > > > > > On Feb 13, 2009, at 4:58 PM, Dan Wilson wrote: > > > > > >> Frankly Henry, the contents of the array matter. Coldfusion makes a > > > >> copy of all simple types and passes a reference of all complex > types. > > > > > >> If you have an array of objects or structs, coldfusion will make a > new > > > >> array with a reference to the objects inside. Changing any of those > > > >> objects will be reflected in both arrays. However, simple types are > > > >> not passed by reference, so changing one of those would only be > > > >> reflected inside the source array that was mutated. > > > > > >> Make sense? > > > > > >> Dan > > > > > >> On 2/13/09, Henry <[email protected]> wrote: > > > > > >>> Anyone knows what's the reason behind passing array by value, not > by > > > >>> reference, in CF? > > > > > >>> I totally forgot about it today and it cost me valuable time... > > > > > >>> Henry Ho > > > > > >> -- > > > >> "Come to the edge, he said. They said: We are afraid. Come to the > > > >> edge, he said. They came. He pushed them and they flew." > > > > > >> Guillaume Apollinaire quotes > > > > -- > > E: [email protected] > > W:www.compoundtheory.com > > > -- E: [email protected] W: www.compoundtheory.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en -~----------~----~----~----~------~----~------~--~---
