Annotation of loncom/html/adm/help/tex/Spreadsheet_Ternary_Operator.tex, revision 1.3
1.2 bowersj2 1: \label{Spreadsheet_Ternary_Operator}
1.3 ! bowersj2 2: The ?\index{? :}'s and :'s seen in the spreadsheet cells are part of
! 3: compact notation for an if-then-else clause. Something like:
1.1 bowersj2 4:
5: \texttt{( B2 > 16 ? 'passing grade' : 'failing grade')}
6:
7: can be translated into:
8:
9: \texttt{if (B2 > 16 ) \{ \\
10: \hspace*{16pt} \$temp = 'passing grade';\\
11: \} else \{ \\
12: \hspace*{16pt} \$temp = 'failing grade'; \\
13: \} \\
14: \$temp;\\
15: }
16:
1.2 bowersj2 17: The nicest part of the \texttt{( ? : )} operator (aside from its
18: compactness) is the way it automatically returns the value you want
19: without having to use any temporary variables.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>