Chapsterj
Chapsterj

Reputation: 6625

coldfusion IIF statement with parameters

I'm working on a coldfusion line trying to work out what this line means. I'm new to CF so excuse my ignorance.

<CFSET is_box = IIF(_boxes[1].name EQ application.box,1,0)>

I presume _boxes is an array of objects and if the index 1 in that array is equal to application.box then what does 1, 0 mean. Is it like a shorthand js statement where is does the below.

is_box = ( _boxes[1].name == application.box ) ? 1 : 0;

Upvotes: 0

Views: 920

Answers (1)

Henry
Henry

Reputation: 32915

Is it like a shorthand js statement where is does the below.

yes it is, except the string comparison is case-insensitive.

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7f4f.html

edit: You may, if you're using CF9 or above, refactor it into

<CFSET is_box = _boxes[1].name EQ application.box ? 1 : 0>

Upvotes: 2

Related Questions