This content has been marked as final. Show 3 replies
I consider a structure to be like a big box into which you can put variables. Then, if you send the structure somewhere, to a cfc for example, all the variables go with it.
I consider an array to a way of arranging data.
To display query results on a page, for the most part, forget arrays and structures. All they do is complicate things.
However, if you want to be confused even more than you are now, a query can be viewed as a structure containing a bunch of one dimensional arrays. The arrays are your columns, not your rows. The usefulness of this is that you can use array functions, such as arraysum(), on your query.
Didn't clear things up a bit, did it.
An array is an ordered set who's indices are whole numbers. Members are referenced by a particular number.
a = "John";
a = "Mary";
a = "Tom";
The order of an array is important.
A structure (analogous to a hash map, associative array) is a data structure who's keys or "indices" can be alpha-numeric values. The members are referenced by these values.
s["name1"] = "John";
s["name2"] = "Mary";
s["name3"] = "Tom";
One notable difference betwen the 2 In coldfusion, is that arrays are passed by value, and structs by reference.
Another thing to remember when comparing the two is that ColdFusion provides a lot more searching functionality for lists and structures that it does for arrays. There are uses for both and sometimes a use for a combination. Right now I am using a security scheme that parses and array of structures. It works very nicely.