Skip to content

Commit cb51882

Browse files
authored
Merge pull request #1707 from JoelNiemela/arraylen-sparse-array
Add note on `arrayLen` for corner case with sparse array
2 parents 967bd0e + 3e003ed commit cb51882

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

data/en/arraylen.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"member":"someArray.len()",
66
"returns":"numeric",
77
"related":["arrayAvg"],
8-
"description":"Determines the number of elements in an array.\n CF MX: this function can be used on child XML objects.",
8+
"description":"Determines the largest index in an array.\nFor dense arrays, this corresponds to the number of elements in the array.\n CF MX: this function can be used on child XML objects.",
99
"params": [
10-
{"name":"array","description":"An array which to determine length","required":true,"default":"","type":"array","values":[]}
10+
{"name":"array","description":"An array from which to get the final index.","required":true,"default":"","type":"array","values":[]}
1111
],
1212
"engines": {
1313
"coldfusion": {"minimum_version":"3", "notes":"The member function cannot be called on literals", "docs":"https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-a-b/arraylen.html"},
@@ -23,16 +23,22 @@
2323
],
2424
"examples": [
2525
{
26-
"title": "Simple example for arrayLen function",
27-
"description": "Uses the arrayLen function to get the total length of an array",
26+
"title": "Using arrayLen to get the length of a dense array",
27+
"description": "Uses the arrayLen function to get the total length of a dense array",
2828
"code": "numberArray = [1,2,3,4];\nwriteOutput(arrayLen(numberArray));",
2929
"result": "4"
3030
},
3131
{
32-
"title": "Total length of an array using the member function",
33-
"description": "CF11+ Lucee4.5+ Uses the len member function is the same as running arrayLen.",
32+
"title": "Using member function to get the length of a dense array",
33+
"description": "CF11+ Lucee4.5+ Using the len member function is the same as running arrayLen.",
3434
"code": "colorArray = ['Green','red','blue'];\nwriteOutput(colorArray.len());",
3535
"result": "3"
36+
},
37+
{
38+
"title": "Using arrayLen on a sparse array",
39+
"description": "Uses the arrayLen function to get the largest index of a spare array",
40+
"code": "sparseArray = [];\nsparseArray[42] = 42;\nwriteOutput(arrayLen(sparseArray));",
41+
"result": "42"
3642
}
3743
]
3844
}

0 commit comments

Comments
 (0)