ok...in ColdFusion, a 2d array is a 1d array of 1d arrays.  i think
that's the first sentence in the docs under '2d arrays'.  that's all
well and good.

i'm curious tho...is there any recommendation regarding the 2nd
'dimension' being uniform length?  for example, if I have the
following:

<cfscript>
     my_test = arrayNew(2);

     my_test[1][1] = "foo";
     my_test[1][2] = "bar";
     my_test[1][3] = "foobar";

     my_test[2][1] = "foo1";
     my_test[2][2] = "foo2";
</cfscript>

... is that 'legal'?  or should my_test[2] have a 3rd element in the
2nd dimension?

If i'm in a situation where i'm going to have inconsistent numbers of
elements in the 2nd dimension...is it 'better form' to create 1
dimensional arrays and then manually create a new array within each, a
la:

<cfscript>
     my_test = arrayNew(1);

     my_test[1] = arrayNew(1);
     my_test[1][2] = "foo";
     my_test[1][2] = "bar";
     my_test[1][3] = "foobar";

     my_test[2] = arrayNew(1);
     my_test[2][1] = "foo1";
     my_test[2][2] = "foo2";
</cfscript>

while the 2nd example is certainly the "longer way around", it seems
cleaner, in that each 'nested array' is created independently of the
other, and therefore shouldn't care about different lengths.

maybe i'm just being anal...but i feel like if i create a 2d array,
then there is a distinct 'relationship' between all of the 2nd
dimension values...and they should all be of a uniform length.

is there any 'rule of thumb' as far as this is concerned?

thx!

--
Charlie Griefer

================================================
Marta was watching the football game with me when she said,
"You know, most of these sports are based on the idea of one group
protecting its territory from invasion by another group."
"Yeah," I said, trying not to laugh. Girls are funny.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to