Search code examples
coldfusioncoldfusion-9fw1

CF9 cfscript, passing dynamic array in arguments


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!


Solution

  • 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).