Highlighted

Just curious - struct and array

LEGEND ,
Dec 29, 2016

Copy link to clipboard

Copied

Hello, all,

Just curious:  In ColdFusion, why does an array have a length, but a struct has a count?  You can take an array and get

arrayLen(array)

, but you can't

structLen(struct)

, it has to be

structCount(struct)

.

No biggie.. just curious.

V/r,

^_^

Views

119

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Just curious - struct and array

LEGEND ,
Dec 29, 2016

Copy link to clipboard

Copied

Hello, all,

Just curious:  In ColdFusion, why does an array have a length, but a struct has a count?  You can take an array and get

arrayLen(array)

, but you can't

structLen(struct)

, it has to be

structCount(struct)

.

No biggie.. just curious.

V/r,

^_^

Views

120

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 29, 2016 0
Adobe Community Professional ,
Dec 30, 2016

Copy link to clipboard

Copied

I think that 'len' measures objects that grow, one distinct unit at a time, in one dimension. For example, lists, arrays and Java objects (len(object) = number of characters).

Whereas 'count' measures objects that grow in one dimension, one composite entity at a time. For example, structs (which comprise key-value pairs) and (query) records (which comprise data rows) and ListValues (which may comprise composite entities such as objects).

My guess is that the Coldfusion naming team came to the naming system intuitively. Then the system stayed with tradition.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 30, 2016 0
LEGEND ,
Dec 30, 2016

Copy link to clipboard

Copied

Hi, BKBK,

Thanks for the input.  That makes sense.  I just didn't originally see the differences between something that grows unit vs composite.  I just assumed that even something with a key/value pair, or something that can be composited, still has to have a base (which, I assume, would comprise length).  But if there are multiple sub-components, then length wouldn't really be a precise measure.

Have a great New Year!

V/r,

^_^

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 30, 2016 0