tracker issue : CF-4202075

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] ER for: array[first:end] to be array[first:last]

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Aaron Neff / ()

Created: 04/21/2018

Components: Language, Expressions

Versions: 2018

Failure Type: Others

Found In Build/Fixed In Build: / 2018,0,0,308771

Priority/Frequency: Normal /

Locale/System: / Platforms All

Vote Count: 0

This ER is for array[first:end] to be array[first:last]

Repro:

<cfscript>
  myArray = [1,2,3,4]
  writeDump(myArray[2:3])//returns [2] (expected [2,3])
  writeDump(myArray[2:2])//returns [] (expected [2])
</cfscript>

Notes:
- In CF, "index" always means "the index that you want to reference", not ever "the index before the index that you want to reference".
- It seems there's a 50/50 split wrt which languages have the current behavior (i.e. 'end') vs proposed behavior (i.e. 'last').
- However, 100% of the languages w/ 1-based array indexing use the proposed behavior (i.e. 'last').

Related URL: https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/using-arrays-and-structures/basic-array-techniques.html

Related URL: https://en.wikipedia.org/wiki/Comparison_of_programming_languages_%28array%29#Array_system_cross-reference_list

Related URl: https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(array)#Slicing

Related thread: https://forums.adobeprerelease.com/coldfusionpr/discussion/349/array-slicing

Attachments:

Comments:

Hi Adobe, Is there any reason CF didn't just use mid() and arraySlice() as a guide and treat the 2nd parameter in array[2:3] as "length" instead of "index"? Is it too late to change? For consistency? Thanks!, -Aaron
Comment by Aaron N.
27417 | April 27, 2018 07:18:02 AM GMT