Flow of Control Statements

if / else

fn main () ~> int {
	
	if 0 < 3 { return 8; } 
	else { return 0; }
	return 0;
}

for, break, continue

fn main () ~> int {
	
	for x in 0 .. 3 {
		
		if x == 1 { continue; }
		if x == 2 { break; }
	}
	return 0;
}

while

fn main () ~> int {
	
	while 2 < 3 { 
		printf("hello \n"); 
	}
	return 0;
}

switch

fn main () ~> int {
	
	x = 3;
	switch x { 
		case 0 { return 3; }
		case 1
		case 2 { return 4; }
	}
	return 0;
}

try / catch

Rules

Example
fn main () ~> int {
	
	try {
		sub1(3);
	} catch {
		//handle error
	}
	return 0;
}

fn sub1 (uint x) -> int throws {
	if x > 0 { throw; }
	return -x;
}