Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);

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?

like image 573
Mohamad Avatar asked Jul 11 '11 16:07

Mohamad


1 Answers

<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

like image 114
Henry Avatar answered Sep 21 '22 18:09

Henry