Advanced Computing Environment
Hosted by SourceForge
brix-os project page

Previous: Objects ----- Up: Contents ----- Next: Loops and Iterators


show notes
Features that need to be added to the page or ideas that haven't been thought out.
  • error category exceptions thrown by the condition will be handled as a false condition. condition value can be ignored if exceptions are thrown. (if `ignore (line = read()) ... else ...) the end_of_file_error would be a false condition.
  • conditional value operator
    	// return value based on condition
    	condition ? (true_value, false_value)

The IF extension executes a body of code if the evaluated condition is true. The optional ELSE body is executed when the condition is false. The optional comma is not allowed when the entire condition is wrapped in parentheses or when body1 is a block expression.

IF condition , body1 ELSE body2
  • condition -- Boolean value
  • , -- optional syntax to separate condition and body1
  • body1 -- single or block expression for true conditions
  • ELSE -- required syntax if body2 is given
  • body2 -- single or block expression for false conditions
	if a < b
	  return a
	  return b

When both bodies are single expressions and both return values of similar types, then the IF extension will return the result of the executed expression.

	// C: c = (a < b) ? a : b;
	c = if(a < b) a else b

Previous: Objects ----- Up: Contents ----- Next: Loops and Iterators