Learning ColdFusion 9: The Ternary Operator

<!--- Define post-date action method. --->
<cffunction name="kiss">
	<!--- Woman in question performs random reaction. --->
	<cfreturn ((randRange( 1, 2 ) EQ 2) ? "Kiss back" : "Slap") />
</cffunction>
 
<!--- Define post-date action method. --->
<cffunction name="hug">
	<!--- Woman in question performs random reaction. --->
	<cfreturn ((randRange( 1, 4 ) GT 1) ? "Hug back" : "Kiss back") />
</cffunction>
 
 
<!--- Loop over a number of possible post-date scenarios. --->
<cfloop
	index="scenarioIndex"
	from="1"
	to="7"
	step="1">
 
	<!--- Pick a random date quality for action logic. --->
	<cfset dateQuality = randRange( 1, 10 ) />
 
	<!---
		Try an action using the following logic tree and and see
		what happens:
 
		1. If date quality was estimated at being 7 or better then
			A. Kiss her.
			B. If She kisses back then
				i. Kiss her again
			C. If she slaps you then
				i. Leave ashamed
		2. If date quality was estimated at being worse then
			A. Just hug her (it's cool being friends)
	--->
	<cfset result = (
		(dateQuality GT 7) ?
		(
			(kiss() EQ "Kiss back") ?
			kiss() :
			"Leave ashamed"
		) :
		hug()
		) />
 
	<!--- Output the action result. --->
	Result: #result#<br />
 
</cfloop>

For Cut-and-Paste