inc()

The inc() system function will increment a named variable, either by one (1) or by an optionally passed second value.

Syntax:

method inc(var value: Value, number: Value := 1): Value;
Value inc(ref Value value, Value number = 1);
func inc(_ inout value: Value, _ number: Value = 1) -> Value
Value inc(__ref Value value, Value number = 1);

The resulting type is equivalent to the passed value (referred to as Value above), and can be any Integer, Floating Point or Char type.

Even though the first parameter will be modified, for legacy and compatibility reasons, inc() and inc() can be called without marking the parameter as pass-by-reference.

var x := 5;
inc(x);     // x is now 6
inc(var x); // x is now 7
int x = 5;
inc(x);     // x is now 6
inc(ref x); // x is now 7
var x = 5
inc(x)      // x is now 6
inc(&x)     // x is now 7
int x = 5;
inc(x);     // x is now 6
inc(__ref x); // x is now 7

For C#, Swift and Java, calling inc() with a single parameter is comparable to using the ++ prefix or postfix operator.

int x = 5;
inc(x); // x is now 6
x++;    // x is now 7
var x = 5
inc(x)  // x is now 6
x++     // x is now 7
int x = 5;
inc(x); // x is now 6
x++;    // x is now 7

See Also