0

I just came across a piece of that I am not able to properly look up on Google. It basically looks like this foo([](){bar();}). Here is what I actually found:

ArduinoOTA.onStart([]() {
    Serial.println("Start");
});

Could someone explain this syntax to me or at least tell me what I'm looking at here?

Forivin
  • 13,544
  • 25
  • 91
  • 183
  • Thanks for marking this. I really hate myself for no having known about lambda functions before. They seem to be ridiculously useful. – Forivin Sep 26 '16 at 19:30

2 Answers2

1

It just invokes some function foo with lambda function []() { bar(); } as its argument.

Edgar Rokjān
  • 16,757
  • 4
  • 38
  • 66
1

You're looking for lambda expressions.

In this case, it seems to be registering an action to be performed on start.

krzaq
  • 15,948
  • 4
  • 44
  • 60