Skip to content
This repository was archived by the owner on May 21, 2026. It is now read-only.

Conditional Statements

Austin Lehman edited this page Oct 23, 2022 · 1 revision

In Aussom, conditional statements come in two flavors, if/else if/else blocks, or switch/case/default blocks. Conditional statements can also be used in loops, however we are going to focus on these two in this section.

In Aussom, an 'if' statement is required to have an 'else if' or 'else statement. Below is an example of the syntax for each.

if(false) {
	// Not executed because it's false.
} else if(false) {
	// Not executed because it's false.
} else {
	// Executed, default case.
}

Switch/case/default statements are available as well, but only operate on string values.

switch(var1) {
	case "one": {
		// do something
	}
	case "two": {
		// do something
	}
	default {
		// didn't match 'one' or 'two', do default action.
	}
}

Conditional Operators:

> Greater than.

< Less than.

>= Greater than equal to.

<= Less than equal to.

! Not.

== Equal to.

!= Not equal to.

&& And.

|| Or.

Below are some examples of evaluation of basic conditional statements.

if(10 > 5)			// 10 is greater than 5, so this statement is true.
if(10 < 5)			// 10 is not less than 5, so this statement is false.
if(10 == 10)			// 10 is equal to 10, so this statement is true.
if(10 == 5)			// 10 is not equal to 5, so this statement is false.
if(10 != 5)			// 10 is not equal to 5, so this statement is true.
if(10 != 10)			// 10 is equal to 10, so this statement is false.
if(10 >= 10)			// 10 is equal to 10, so this statement is true.
if(11 >= 10)			// 11 is greater than 10, so this statement is true.
if(10 <= 10)			// 10 is equal to 10, so this statement is true.
if(9 <= 10)			// 9 is less than 10, so this statement is true.
if(true)			// Boolean value of true is true.
if(false)			// Boolean value of false is false.
if(!true)			// Not true is false.
if(1)				// Any integer or double not equal to 0 is true.
if(0)				// Any integer or double that is 0 or 0.0 is false.
if("my string")			// Any non empty string is true.
if("")				// Any empty string is false.
if(null)			// Null is evaluated as false.
if(true && true)		// Both are true, so the and expression is true.
if(true && false)		// One is not true, so the and expression is false.
if(true || false)		// One is true, so the or expression is true.
if(false || false)		// Both are false, so the or expression is false.

Clone this wiki locally