Tuesday, March 22, 2011

Railo does Array's By Reference

I'm working away developing an app in Railo, and I just read Ben Nadel's post about how Coldfusion passes Arrays by Value (which is nuts btw, when you think about it) ... and how to pass an array By Reference using java.util.ArrayList directly.

Thankfully, Railo passes Arrays by Reference! ... and since I'm working on a new project there's no reverse compatibility issue moving from Coldfusion.


arrA = ArrayNew();
ArrayAppend(arrA,"Hello World");
arrB = arrA;
ArrayAppend(arrB,"Hello Jello");
writeDump(arrA);
writeDump(arrB);

Array
1
string Hello World
2
string Hello Jello

Array
1
string Hello World
2
string Hello Jello