请考虑以下文档:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=CFScript_11.html#1161053
我正在研究以下代码的描述:
<cfscript>
//Set the variables
acceptedApplicants[1] = "Cora Cardozo";
acceptedApplicants[2] = "Betty Bethone";
acceptedApplicants[3] = "Albert Albertson";
rejectedApplicants[1] = "Erma Erp";
rejectedApplicants[2] = "David Dalhousie";
rejectedApplicants[3] = "Franny Farkle";
applicants.accepted=acceptedApplicants;
applicants.rejected=rejectedApplicants;
rejectCode=StructNew();
rejectCode["David Dalhousie"] = "score";
rejectCode["Franny Farkle"] = "too late";
描述说,“创建两个一维数组,一个包含已接受的申请人,另一个包含已拒绝的申请人。”
我是 ColdFusion 新手,在上面的代码中没有看到任何使用 array 关键字的数组声明,就像下面的文档一样:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=arrayStruct_03.html#1121128
请解释一下。
最佳答案
您需要初始化 acceptedApplicants
和 rejectedApplicants
数组
应该有
acceptedApplicants = [];
rejectedApplicants= [];
代码上方某处。就像 Peter 所说,如果这是在函数中,请确保对这些变量进行 var 操作。
关于arrays - CFScript 中的数组声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17349296/