ColdFusion 结构一次初始化许多属性
我见过 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,此语法在 cf8 中部分引入,并在 9 中进一步改进。MX7 没有可用的此类构造。
No, this syntax was partially introduced in cf8, and further improved in 9. MX7 had no such construct available.
我们可以做的是创建一个小的 util 函数,从而:
然后可以调用哪个函数,因此:
这几乎以相同的方式工作。从任何角度来看都不是那么好,但这是一种需要注意的方便技术。
What one can do is to create a small util function thus:
Which one can then call, thus:
That pretty much works the same way. Not as nice by any measure, but it's a handy technique to be aware of.