agreed, 100% dave has such an eloquent way of explaining things...

I just cant.

I use arrays for dumb data, and structures for more intelligent data.

I use arrays when I have to order things, add them up, or whatever...

I use structures when I have multi-dimensional data that is easier to
decipher.

anyway, STUDY the heck outta these (Structs and Arrays) since the cfmx cert
exam is laden heavily with their syntax etc...

tw

-----Original Message-----
From: Dave Watts [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 29, 2004 10:52 AM
To: CF-Talk
Subject: RE: first time array

> Tony... why are structures a better way to go than than arrays

While I'm not Tony, I wouldn't say that structures are better than arrays or
vice-versa. They're different, and which is best for you at a specific time
depends on what you're trying to accomplish.

If you're trying to describe the attributes of a single thing, a structure
usually makes more sense. If, on the other hand, you're trying to describe a
bunch of items together, an array usually makes more sense. If you want to
describe the attributes of each item within an array, you can create an
array of structures.

<!--- structure example --->
<cfset mydog = StructNew()>
<cfset mydog.name = "Fido">
<cfset mydog.breed = "Chihuahua">
...

<!--- array example --->
<cfset mycart = ArrayNew(1)>
<cfset mycart[1] = "bread">
<cfset mycart[2] = "milk">
...

<!--- array of structures example --->
<cfset mycart = ArrayNew(1)>
<cfset mycart[1] = StructNew()>
<cfset mycart[1].name = "bread">
<cfset mycart[1].price = 2.5>
<cfset mycart[2] = StructNew()>
<cfset mycart[2].name = "milk">
<cfset mycart[2].price = 2.25>
...

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
phone: 202-797-5496
fax: 202-797-5444
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to