Operator: Short-Circuit Or
Operator: Short-Circuit Or

Operator: Short-Circuit Or

Returns the result of the logical "or" between two values. The values are evaluated as though they were boolean values. Resultant value type is always boolean.

The difference between this operator and logical or is that this will stop evaluation of the rest of the expression if this evaluates as true (or is true-equivalent).

Example

Short-Circuit Or Example


world
{
	function trueFunction()
	{
		textln("Calling trueFunction() - returning true.");
		return true;
	}
	
	function falseFunction()
	{
		textln("Calling falseFunction() - returning false.");
		return false;
	}

	start()
	{
		textln("falseFunction() || trueFunction()");
		textln("Result: " + (falseFunction() || trueFunction()));
		textln("trueFunction() || falseFunction()");
		textln("Result: " + (trueFunction() || falseFunction()));
		quit;
	}
	
}
×

Modal Header