: This article mainly introduces C ++, PHP, Javascript,... and lambda expression Support. if you are interested in PHP tutorials, refer to it. Lambda
Lambda expressions, also known as Closure (Closure), are also called anonymous functions. Thanks to its strength, it is supported by almost all mainstream development languages. This article attempts to list the sample code of lambda expressions in most languages and will continue to be updated later.
PHP's support for lambda
External variables must be explicitly referenced, and the partition value and reference must be passed.
C ++'s support for lambda
#include usingnamespacestd;int main(int argc, char** argv){ int i = 12; int j = 33; auto callable = [i, &j](){ cout << i << endl; cout << j << endl; }; callable(); i++; j++; callable();}
You must display the referenced external variables, pass the partition value, and pass the reference.
Supported[=][&]
To reference all external variables.
Javascript
《script》var i = 12;var j = 33;var callable = function(){ alert(i); alert(j);}callable();i++;j++;callable();
External variables are automatically available without reference.
All variables are passed by reference.