在ColdFusion中使用带有命名参数的冒号 [英] Using a colon with named arguments in ColdFusion

查看:166
本文介绍了在ColdFusion中使用带有命名参数的冒号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个录音中看到这个代码示例,想知道冒号语法做了什么。我搜索了文档,但我找不到任何信息:

I saw this code example in a recording and wanted to know what the colon syntax did. I searched the docs, but I wasn't able to find any info on it:

weather.subscribe(observer:application.observers.currentConditions );

我知道我们可以在CF9中为三元运算符使用冒号:

I know we can use colon in CF9 for ternary operators:

result =(condition)? true:false;

但在这种情况下,它看起来像是用来提供命名参数;

But in this case it looks like it's being used to provide named arguments; so what's it doing there?

推荐答案


< cfset result = obj .func(arg:value,thing:42)/> 我看着这个,
去了闪烁,闪烁 ...不能!不能对
命名参数使用冒号!呃,你能吗?好吧,显然你可以。

<cfset result = obj.func(arg:value,thing:42) /> I looked at this and went blink, blink... That can't be right! You can't use colons for named arguments! Er, can you? Well, apparently you can.

http://corfield.org/blog/post.cfm/Learn_something_new_every_day_named_arguments

这篇关于在ColdFusion中使用带有命名参数的冒号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆