Christian
Christian

Reputation: 117

CFML - Array and Scope - Object of type class coldfusion.runtime.Struct cannot be used as an array

I would like to use scopes for my array variable names.

This example works.

<cfset person_first_name[1] = "John">
<cfset person_first_name[2] = "Jack">
<cfset x = ArrayLen(person_first_name)>

However, this code occures the following error: "Object of type class coldfusion.runtime.Struct cannot be used as an array"

<cfset person.first_name[1] = "John">
<cfset person.first_name[2] = "Jack">
<cfset x = ArrayLen(person.first_name)>

Isn't it possible to name the variables like that?

Upvotes: 2

Views: 954

Answers (1)

Christian
Christian

Reputation: 117

Adding a declaration for the array solved the problem. Thanks @SOS.

<cfset person.first_name = []>

Upvotes: 3

Related Questions