Skip to content

Types

CES uses typed variables.
Each variable must declare a type before its name.


Syntax

The type is declared before the variable name.

Int age : 18;
String name : "Thiago";

Available Types

Type Description
Int Integer numbers
Float Decimal numbers
Str Text values
Bool Boolean values
Inst Object instances
Hex value of Color
List Ordered collection of values
Dict Key-value collection

Int

The Int type stores whole numbers.

Int score : 100;
DisplayLog(score);

Output:

100

Float

The Float type stores decimal numbers.

Float pi : 3.14;
DisplayLog(pi);

Output:

3.14

Str

The Str type stores text.

String message : "hello world";
DisplayLog(message);

Output:

hello world

Hex

The Hex type stores color.

Hex Green : #FF0;
DisplayLog(Green);

Output:

#ffffff00

Bool

The Bool type stores true or false.

Bool active : true;
DisplayLog(active);

Output:

true

Inst

The Inst type stores an object created from a class.

class Person {
    Str name : "John";
}

Inst p : Person();
DisplayLog(p.name);

Output:

John

List

The List type stores multiple values in order.

Example

List friends : ["Paulo", "Pedro", "João"];

DisplayLog(friends[0]);
DisplayLog(friends[1]);
DisplayLog(friends[2]);

Output:

Paulo
Pedro
João

Nested Lists

List data : [[1, 2], [3, 4]];

DisplayLog(data[0][0]);

Output:

1

Count Property

List friends : ["Paulo", "Pedro", "João"];

DisplayLog(friends.count);

Output:

3

Dict

The Dict type stores key-value pairs.

Example

Dict table : { "rice" : 100 , "bean" : 500 };

DisplayLog(table["bean"]);

Output:

500

Nested Values

Dict data : { "nums" : [10, 20, 30] };

DisplayLog(data["nums"][1]);

Output:

20

Count Property

Dict table : { "arroz" : 100 , "milho" : 500 };

DisplayLog(table.count);

Output:

2

Complete Example

Str player : "Lucena";
Int score : 250;
Bool alive : true;
Hex tractor_color: #0F0;
List inventory : ["book", "shield", "potion"];
Dict stats : { "hp" : 100, "mana" : 50 };

DisplayLog("Name: " + player);
DisplayLog("___________________________");
DisplayLog("score: " + score);
DisplayLog("___________________________");
DisplayLog("alive: " + alive);
DisplayLog("___________________________");
DisplayLog("tractor_color: " + tractor_color);
DisplayLog("___________________________");
DisplayLog("current item: " + inventory[0]);
DisplayLog("___________________________");
DisplayLog("hp: " + stats["hp"]);
DisplayLog("_______inventory_______");
for(Int i : 0; i < inventory.count; i += 1){
    DisplayLog("--------------------");
    DisplayLog(inventory[i]);
}
DisplayLog("___________________________");

Output:

Name: Lucena
___________________________
score: 250
___________________________
alive active: True
___________________________
tractor_color: #ff00ff00
___________________________
current item: book
___________________________
hp: 100
_______inventory_______
--------------------
book
--------------------
shield
--------------------
potion
___________________________

Notes

Note

Type names are case-sensitive.

Use Int, not int.