Proper way to populate / duplicate an array using ArrayAppend()
39 views
Skip to first unread message
Jeff Shood
unread,
Mar 3, 2011, 9:35:03 PM3/3/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Railo
Due to the differences between the way Coldfusion duplicates arrays
and how railo passes them as a reference some code I'm migrating from
ACF to Railo is breaking. I'd like to learn the right way to do this.
I'm populating an array that will be of a variable length by using the
code below: ( this is part of an error handling script)
var fileDef = arrayNew(1);
var tempArr = arrayNew(1);
However because Railo passes arrays as a reference in the second block
of code where I change the value of tempArr[2] to CB_filePath, that
change is made to all elements the final array (fileDef)
Should I make a copy of tempArr each time I append to fileDef?
Should I use another function to append?
Should I be doing this a whole different way all-together?
Any advice is appreciated!
AJ Mercer
unread,
Mar 3, 2011, 10:29:36 PM3/3/11
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ra...@googlegroups.com
Like aj write, use the function duplicate before passing the object or with cfargument/the parameter definition you can set the attribute passby="value".