//declare a variable with an initial value
var answer = 42;

//declare a variable without an initial value
var empty;

//assign a previously existing variable
answer = 6 * 9;

//access a variable
answer = answer + 1;

//compound assignments
answer += 5;
answer -= 5;
answer *= 9;
answer /= 2;
answer %= 10;

//equality checks
print 1 == 1; //true
print 1 != 1; //false

//comparison checks
print 1 < 2; //true

print "foo" > "bar"; //true

print 1 < 2; //true
print 1 > 2; //false

print 2 <= 2; //true
print 2 >= 2; //true

print 1 <= 2; //true
print 1 >= 2; //false

//logical checks
print true && true; //true
print true && false; //false
print false && true; //false
print false && false; //false

print true || true; //true
print true || false; //true
print false || true; //true
print false || false; //false

print !true; //false
print !false; //true

//logical AND short-circuits and chained assignments
{
	var a = 1;
	var b = 2;
	var c = a + 1 && b + 2;

	assert a == 1, "short circuit 1.1";
	assert b == 2, "short circuit 1.2";
	assert c == 4, "short circuit 1.3";
}

{
	var a = 1;
	var b = 2;
	var c = a = (a + 1) && b + 2;

	assert a == 4, "short circuit 2.1";
	assert b == 2, "short circuit 2.2";
	assert c == 4, "short circuit 2.3";
}

{
	var a = 1;
	var b = 2;
	var c = a = a + 1 && b + 2;

	assert a == 4, "short circuit 3.1";
	assert b == 2, "short circuit 3.2";
	assert c == 4, "short circuit 3.3";
}

//logical OR short-circuits and chained assignments
{
	var a = 1;
	var b = 2;
	var c = a + 1 || b + 2;

	assert a == 1, "short circuit 4.1";
	assert b == 2, "short circuit 4.2";
	assert c == 2, "short circuit 4.3";
}

{
	var a = 1;
	var b = 2;
	var c = a = (a + 1) || b + 2;

	assert a == 2, "short circuit 5.1";
	assert b == 2, "short circuit 5.2";
	assert c == 2, "short circuit 5.3";
}

{
	var a = 1;
	var b = 2;
	var c = a = a + 1 || b + 2;

	assert a == 2, "short circuit 6.1";
	assert b == 2, "short circuit 6.2";
	assert c == 2, "short circuit 6.3";
}

//types
{
	var a: Int;
	var b: Int = 42;

	a = 69;
	b = 8891;

	print a;
	print b;
}

//constants
{
	var c: Int const = 42;
	print c;
}

//indexing
{
	var s = "Hello" .. "world!";
	print s[3, 3];
}

//increment & decrement (prefix)
{
	var a = 42;
	assert a == 42, "prefix increment & decrement 1.1";
	assert ++a == 43, "prefix increment & decrement 1.2";
	assert a == 43, "prefix increment & decrement 1.3";
	assert --a == 42, "prefix increment & decrement 1.4";
	assert a == 42, "prefix increment & decrement 1.5";
}

//increment & decrement (postfix)
{
	var a = 42;
	assert a == 42, "postfix increment & decrement 1.1";
	assert a++ == 42, "postfix increment & decrement 1.2";
	assert a == 43, "postfix increment & decrement 1.3";
	assert a-- == 43, "postfix increment & decrement 1.4";
	assert a == 42, "postfix increment & decrement 1.5";

	print a;
}

//TODO: type casting