When creating an array or structure, CF allows things like this:

<cfset myArray[1] = "foo" />
<cfset myStruct.1 = "foo" />

But if the variable has been previously set to a different data type
(string in this case) like so:

<cfset myArray = "foo" />
<cfset myStruct = "foo" />

<cfset myArray[1] = "foo" />
<cfset myStruct.1 = "foo" />

the following error is received:

You have attempted to dereference a scalar variable of type class
java.lang.String as a structure with members.


You must specifically declare the variable as the new data type to
prevent errors:

<cfset myArray = "foo" />
<cfset myStruct = "foo" />

<cfset myArray = arrayNew(1) />
<cfset myStruct = structNew() />

<cfset myArray[1] = "foo" />
<cfset myStruct.1 = "foo" />

Was this a problem in CF5? Is this an expected behavior or a bug in
CFMX? It should be mentioned that going the opposite direction works
just fine:

<cfset myArray[1] = "foo" />
<cfset myStruct.1 = "foo" />

<cfset myArray = "foo" />
<cfset myStruct = "foo" />

Your thoughts...

chris kief


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to