Did you guys re-implement struct to work with some/all array functions on purpose in Lucee 5.3?


#1

Did you guys re-implement struct to work with some/all array functions on purpose in Lucee 5.3?

This behavior doesn’t work in Lucee 5.2.x or prior versions and I was surprised to see this work.

<cfscript>
struct = {};
if(not structkeyexists(struct, "key")){
	struct["key"]={};
}
writedump(getmetadata(struct["key"])); // class is 	lucee.runtime.type.StructImpl
arrayAppend(struct["key"], "value");
writedump(getmetadata(struct["key"])); // class is still lucee.runtime.type.StructImpl, yet the array operation worked.
writedump(struct["key"]); // now has a key of 1 with value of "value".
abort;
</cfscript>

This behavior makes struct more similar to the query result object in that it is both array and struct. Languages like Javascript have always been flexible like that too. Was that the inspiration for this?

Would the documentation need to change if this is a feature?


#2

Related to https://luceeserver.atlassian.net/browse/LDEV-1892 ?