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