Lambda
A lambda expression, also called closure (closure), is also called an anonymous function. Because of its strength, almost supported by all the mainstream development languages, this article attempts to list the sample code for lambda expressions in most languages, followed by continuous updates.
PHP support for Lambda
$i = 12;$j = 33;$callable = function()use($i, &$j){echo$i . "\n"; echo$j . "\n";};$callable();$i++;$j++;$callable();
- You must explicitly reference external variables, differentiate between values and reference passing.
Support for Lambda in C + +
#include
usingnamespacestd;int main(intchar** argv){ int12; int33; auto callable = [i, &j](){ cout << i << endl; cout << j << endl; }; callable(); i++; j++; callable();}
- You must display reference external variables, differentiate between value passing and reference passing.
- Support
[=][&]
for simple syntax to refer to all external variables.
Javascript
以上就介绍了C++、PHP、Javascript、...、对lambda表达式的支持,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。