On Tuesday, September 3, 2002, at 07:01 , Joe Eugene wrote:
> Ben Forta actually explains this in detail in one of his CF5.0 books and
> it
> actually looked powerful..
Oh dear... It's unfortunate that Ben documented something that wasn't even
supposed to be legal...
>>> <cfset Result=iif(x,"z='Arg1';5","z='Arg2';10")>
> Anyways i guess re-write....
To be honest, this sort of code is really bad practice - multiple
operations kludged together like that. Any programmer on my team who did
that would be taken out a summarily shot! (to misquote Andrew Koenig)
After all, 'iif()' is already verboten here by our coding guidelines, as
is 'evaluate()' (unless you can *prove* you need to use it). These
constructs lead to ugly, unmaintainable code.
It's much, much clearer to write:
<cfif x>
<cfset result = 5/>
<cfset z = arg1/>
<cfelse>
<cfset result = 10/>
<cfset z = arg2/>
</cfif>
or:
<cfscript>
if ( x ) {
result = 5;
z = arg1;
} else {
result = 10;
z = arg2;
}
</cfscript>
You should bear in mind that your original code is akin to this in C/C++:
result = x ? (z = arg1, 5) : (z = arg2, 10);
No self-respecting C/C++ programmer would write such a monstrosity!
Sean A Corfield -- http://www.corfield.org/blog/
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists