Title here
Summary here
Go supports constants of character, string, boolean, and numeric values.
const
declares a constant value.
class ConstantsExample extends Object;
const
string S = "constant";
function Main() {
`log(S);
}
const
int N = 500000000;
const
float D = 3e20 / N;
function Main() {
`log(D);
`log(trunc(D));
`log(Sin(N));
}
A const
statement can appear anywhere a var
statement can. Here’s the constant declaration and its usage within a function.
const
int N = 500000000;
Constant expressions perform arithmetic with arbitrary precision.
const
float D = 3e20 / N;
function Main() {
`log(D);
}
A numeric constant has no type until it’s given one, such as by an explicit conversion.
function Main() {
`log(trunc(D));
}
A number can be given a type by using it in a context that requires one, such as a variable assignment or function call. For example, here Sin
expects a float
.
function Main() {
`log(Sin(N));
}
To run this UnrealScript example, compile and execute within your UnrealScript editor or engine environment.