Skip to content

Anonymous Functions

CD2 edited this page Feb 8, 2023 · 1 revision

Anonymous functions can only be called with function pointer calls. Anonymous functions can refer to local variables. Anonymous functions cannot be defined on class members or globally.

Literals

If the function definition is enclosed in [] without writing the name, it becomes an anonymous function literal. Anonymous function literals can be written inside expressions.

void f()

{

int sum = [int(int a, int b){ret a + b;}](:1, 1:);

}

Clone this wiki locally