• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Just curious - struct and array

LEGEND ,
Dec 29, 2016 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

178

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
community guidelines
Community Expert ,
Dec 30, 2016 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.

Votes

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
community guidelines
LEGEND ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

LATEST

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,

^_^

Votes

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
community guidelines
Resources
Documentation