gpt4 book ai didi

arrays - 数组参数,默认为空

转载 作者:行者123 更新时间:2023-12-02 06:59:04 24 4
gpt4 key购买 nike

我想将可选的数组参数传递给函数。如果未提供参数,则数组应为空。我尝试了以下方法:

<cfargument name="time_blocks" type="array" required="false" default="[]">

但我收到以下错误:

invalid call of the function CreateRateBlock
14th Argument (time_blocks) is of invalid type, can't cast String [] to a value of type [array]

我也尝试过这个:

<cfargument name="time_blocks" type="array" required="false" default="">

在这种情况下,错误几乎是相同的:

invalid call of the function CreateRateBlock
14th Argument (time_blocks) is of invalid type, can't cast String [] to a value of type [array]

我还尝试删除默认属性,但在这种情况下,time_blocks 的值为 null。我做错了什么?

最佳答案

[] 不起作用,因为它只是一个 2 个字符的字符串 "[]"

#[]# 从技术上讲应该可以工作,但旧的 CF 不够智能。所以使用:

<cfargument name="time_blocks" type="array" required="false" default="#arrayNew(1)#">

关于arrays - 数组参数,默认为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27827684/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com