ColdFusion 结构一次初始化许多属性

发布于 2024-12-22 21:00:47 字数 344 浏览 0 评论 0原文

我见过 ColdFusion 9 代码一次初始化结构的许多属性。 这是一个例子:

<!--- 
 pseudo constructor code 
--->
<cfset variables.instance = {
            first_name  = '',
            last_name   = '',
            gender      = '',
            dateofbirth     = ''
            } />

有没有办法在 coldfusion MX7 中做到这一点?

I have seen ColdFusion 9 code which initializes many properties of a structure at a time.
Here is an example:

<!--- 
 pseudo constructor code 
--->
<cfset variables.instance = {
            first_name  = '',
            last_name   = '',
            gender      = '',
            dateofbirth     = ''
            } />

Is there a way to do this in coldfusion MX7 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

潇烟暮雨 2024-12-29 21:00:47

不,此语法在 cf8 中部分引入,并在 9 中进一步改进。MX7 没有可用的此类构造。

No, this syntax was partially introduced in cf8, and further improved in 9. MX7 had no such construct available.

治碍 2024-12-29 21:00:47

我们可以做的是创建一个小的 util 函数,从而:

function structBuild(){
    return arguments;
}

然后可以调用哪个函数,因此:

st = structBuild(
    first_name  = '',
    last_name   = '',
    gender      = '',
    dateofbirth = ''
);

这几乎以相同的方式工作。从任何角度来看都不是那么好,但这是一种需要注意的方便技术。

What one can do is to create a small util function thus:

function structBuild(){
    return arguments;
}

Which one can then call, thus:

st = structBuild(
    first_name  = '',
    last_name   = '',
    gender      = '',
    dateofbirth = ''
);

That pretty much works the same way. Not as nice by any measure, but it's a handy technique to be aware of.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文