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
  • 14,780
  • 27
  • 106
  • 199
  • 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
  • 17,245
  • 4
  • 40
  • 67
1

You're looking for lambda expressions.

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

krzaq
  • 16,240
  • 4
  • 46
  • 61