Using the var
Keyword
In Coco, the var
keyword is your key to declaring variables effortlessly. Just provide the variable names followed by their respective types, as shown in Variable.DeclareVar()
Direct Value Assignment
Experience the convenience of direct value assignment! Coco automatically determines the variable's type based on the assigned value, as shown in Variable.DeclareValue()
Defining Constants Using const
Keyword
Constants can be defined for the whole module using const
keyword. Constant’s definition needs to include both type and value.
Retrieval of variable type with typeof
A string description of variable type can be retrieved using typeof(variable)
function. Any variable or expression can be the argument, except functions. Calling functions in typeof()
produces a compiler error.
typeof() is implemented in cocolang v0.3.1
coco Variable
const VAL U64 = 10
endpoint invokable DeclareVar() -> (output U64):
var n U64
n = VAL
yield output n
endpoint invokable DeclareValue() -> (output U64):
var n = 10
yield output n