在ColdFusion中使用带有命名参数的冒号 [英] Using a colon with named arguments in 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屋!