The function does not work in ESP8266

That's exactly the trap. And I've seen it snap shut so many times in the many decades I deal with programming.
So my experience is not to do so. A function should be left with the last closing brace. And a return that's returns a value should be immediately before that brace. It can save you a lot of troubleshooting.
The only circumstances where I see it valuable to have a return at the beginning of a function, if an error condition is detected that makes it useless to execute the function at all.

1 Like