cobalt-lang/examples/test.cobalt

25 lines
637 B
Plaintext

# Statement tests
print "These are statement tests for Cobalt!";
print 10 + 12;
print 13 + (14 - 7) * 3;
print "Hello, " + "World!";
print "String " + "Multiplication " * 3;
# Variable declaration
var a = 10;
print ("a is " + a);
# Nullable variable declaration
var b? = nil;
print ("b is " + b);
# Examples of structured block statements with scoping
{
print "we are now in a nested scope!";
# Don't really like this behaviour, as I think it should throw a runtime error
# Instead it pulls a's state of 10 in the upper environment block
# Still trying to resolve this...
var a = a + 5;
print ("a is " + a);
}