C + +, PHP, Javascript 、...、 support for lambda expressions

Source: Internet
Author: User
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教程有兴趣的朋友有所帮助。

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.