Quick actions

cmd+k|ctrl+k

Navigation

Languages

Simple Lambdas

Snippet info

Language

Cpp

Visibility

public

Author

evine

Created

2016-01-20T05:43:55Z

Updated

2016-01-20T05:50:21Z

#include <stdio.h>

int main() {
    
    int apple = 40;
    int pear = 3;
    
    
    // Expose only spesific locals to a scope.
    /*Type ThingName = */ [&pear /*Special Argument*/ ](/*Normal Type Argument*/)
    {
        pear = pear + 2;
        //apple = apple + 3; // Error
        printf("%i\n",pear);
    }(/*Normal Argument*/);//Runs inline. If it returns something, it returns like the function under. 
    
    
    auto SomeFunction = [/*Special Argument*/](/*Normal Type Argument*/)
    {
        printf("eoke\n");
    };//Returns a Function(or rather "some unspecified functor type"). The function itself returns the variable.
    
    SomeFunction(/*Normal Argument*/);
    
    
    
    printf("%i\n",pear);
    printf("%i\n",apple);
    return 0;
}
INFO