Anvil | Smiths Smiths | Register Register | Login Login |
Search:
Show links Show tools Show tree | Previous document Next document | njet.org > Anvil > Documentation > Language reference > Expressions > Conditionals

Conditionals

Conditional is shorthand for an if statement. If a conditional expression evaluates to "true", then conditional yields whatever if-true yields; otherwise, if-false is yielded. If if-false is omitted, then ``undefined´´ is used.

A conditional with double question marks yields value if it is "true", otherwise it yields if-false. There is the similarity that ``x ?? y´´ is almost the same as ``x ? x : y´´, except that x is evaluted only once. This conditional is useful as a default value hook.

  cond-expr := exprcondition "?" exprif-true ":" exprif-false 
  cond-expr := exprcondition "?" exprif-true ":"  
  cond-expr := exprvalue "??" exprif-false 
See also  | Expressions  | Grammar
Contributes notes:
Add a note
What's new | Anvil