Function (Callback) Types

Function (callback) types are used for representing functions with an internal type.

For valid internal types, function types can be declared using the type() syntax as follows:

1
2
3
4
5
6
7
// Declare the function with a function type... but do not call it
void() foo = void() {
    // ...
};
 
// The function can now be called later
foo();

Nested Functions

JS++ supports types for nested functions via multiple () operators in the type annotation:

1
2
3
4
5
6
7
8
9
import System;
 
void()() nested = void() () {
    return void() {
        Console.log("Nested functions");
    };
};
 
nested()();

See Also

Share

HTML | BBCode | Direct Link