version 1.1, 2002/07/22 21:08:18
|
version 1.2, 2002/07/26 19:53:59
|
Line 1
|
Line 1
|
|
\label{Spreadsheet_Ternary_Operator} |
The ?'s and :'s seen in the spreadsheet cells are part of compact notation for an if-then-else clause. Something like: |
The ?'s and :'s seen in the spreadsheet cells are part of compact notation for an if-then-else clause. Something like: |
|
|
\texttt{( B2 > 16 ? 'passing grade' : 'failing grade')} |
\texttt{( B2 > 16 ? 'passing grade' : 'failing grade')} |
Line 12 can be translated into:
|
Line 13 can be translated into:
|
\$temp;\\ |
\$temp;\\ |
} |
} |
|
|
The nicest part of the ( ? : ) operator (aside from its compactness) |
|
is the way it automatically returns the value you want without having |
|
to use any temporary variable.s |
|
|
|
|
The nicest part of the \texttt{( ? : )} operator (aside from its |
|
compactness) is the way it automatically returns the value you want |
|
without having to use any temporary variables. |
|
|