Frage

I start this year with a big question. When I do

myName = "Henry";
myCustomFunction( [ myName, "Thierry" ] );

It throws an error like myName is undefined. Why?

I can resolve this by doing

myName = "Henry";
aMyArrayArgument = [ myName, "Thierry" ];
myCustomFunction( aMyArrayArgument );

But still, I want to know why Coldfusion don't allow to pass [ myName, "Thierry" ] in arguments?

I use Framework One (FW/1) if it can help.

Thank you!

War es hilfreich?

Lösung

If your actual code looks more like this:

if (something)
{
    myName = "Henry";
    myCustomFunction( argname=[ myName, "Thierry" ] );
}

Then it's because the literal struct and array notation in CF is very badly written and buggy.

If you can confirm the circumstances it breaks, raise an issue with Adobe (there are several issues relating to this already; you may or not feel like checking for duplicates).

Andere Tipps

If I do this:

 <cffunction name="xx" returntype="void">
     <cfargument name="x" type="array">
     <cfdump var="#arguments.x#">
 </cffunction>

 <cfset myname = "dan">
 <cfset xx([myname, 'bracuk']) >

The code runs without error and I see the dump. There must be something else going on with your code.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top