-1

I am building some HTML forms handlers using ESP32 in Arduino.

In a lot of tutorials I see something like the following...

update_server.on("/", HTTP_GET, []() {
    blah;
    blah;
 });

And here is another..

update_server.on("/update", HTTP_POST, []() {
    blah;
    blah;
}, []() {
    more blah;
    etc... 
});

Can someone please explain to me the [] and the () parts?

I have some vague feeling about these representing function calls, but I am having trouble finding references to this particular syntax.

Thanks, Mark.

Cool Javelin
  • 776
  • 2
  • 10
  • 26
  • 2
    They are [lambda expressions](https://en.cppreference.com/w/cpp/language/lambda) -- in other words, an adhoc function. Read the documentation to see how the capture and parameter lists work. – paddy Nov 26 '21 at 03:42

1 Answers1

3

Those are lambda functions. They are functions without a name basically.

You can read more about it here: https://www.tutorialspoint.com/lambda-expression-in-cplusplus