0

When I convert list into array, the values are inserted starting from index 1. Index 0 is left empty.

Why is this happening, and more importantly, is there a way to change it so that it starts from 0 index?

Example:

<cfset myList = "A,B,C,D" />
<cfset myArray = ListToArray(myList) />
<cfdump var="#myArray#" />
2
  • (Edit) No. As others mentioned, CF arrays use base 1. So there is no index 0. Why do you want to change it? ie What problem are you trying to solve? Commented Jun 26, 2012 at 20:30
  • yourStructure[0] = "something" will work! ;) Commented Jun 28, 2012 at 2:39

1 Answer 1

7

Cause ColdFusion Arrays start at one. Are you actually referncing the 0 position and not getting an error?

Why did the designers of ColdFusion decide to index arrays from 1 rather than 0?

Sign up to request clarification or add additional context in comments.

3 Comments

you could actually reference the zero in an array -- what? How's that?
@Sergii: Wasn't saying you could, just putting that in response to the original question (Eleeist made it sounds like he could reference the zero poisition without an error "Index 0 is left empty")
@Sergii: I edited my question to make my statement less ambiguous.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.