I am playing around with callback functions but one question came up:
When I define callback for the webserver like this:
server.on("/",calbackfunction)
every thing is fine.
I can also do it like this:
[/server.on("/",[]() {
})code]
I am playing around with callback functions but one question came up:
When I define callback for the webserver like this:
server.on("/",calbackfunction)
every thing is fine.
I can also do it like this:
[/server.on("/",[]() {
})code]
I suspect that something got mangled in the attempted placement of code tags in that second example.
Did you have a question?
You can do it that way (don't know if this is what you're asking).
[](){}
This construct is called a lambda, if your function is going to be short enough, or simply you want it inline with the code, you can use this instead of a function callback.
If you're familiar with JavaScript, lambdas also can be considered closures.