Main Index : Reference :

const


Description

Declares a global variable as constant.

Usage

const var variable = [string,int,float] value;

Parameters

variable is the name of the variable.
value is the assign value.

Declaration

const declares a variable as constant. This means that its value cannot be changed, so the variable must be assigned a value directly when it is declared. Constants can only be declared globally. Since C.O.F.F.E.E. has no preprocessor, only simple values like numbers or strings can be directly assigned to global variables.

Example

// Declares MAX_OBJECTS as a constant.

const var MAX_OBJECTS = 100;

function()
{
  // Error. One cannot change constant variables!
  MAX_OBJECTS = 20;
}


// These lines will generate an error. One cannot assign 
// expressions or objects to global variables.

const var x = 5 + 8.0/16 + cos(7.0);
const var y = new(myClass,2,3);

See Also

var