Skip to main content
Known Participant
April 21, 2006
Answered

stucture vs array

  • April 21, 2006
  • 3 replies
  • 446 views


hello
i am still a bit confused from the 2
stucture vs array

how are these used for maybe reporting system.
like
display a query results to a page.
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer BSterner
An array is an ordered set who's indices are whole numbers. Members are referenced by a particular number.

a[1] = "John";
a[2] = "Mary";
a[3] = "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.

3 replies

BSternerCorrect answer
Inspiring
April 22, 2006
An array is an ordered set who's indices are whole numbers. Members are referenced by a particular number.

a[1] = "John";
a[2] = "Mary";
a[3] = "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.
Participant
April 23, 2006
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.

- JS
Inspiring
April 22, 2006
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.