Why does replace() function not work before setup() function?

Dear Perehama, PieterP, SteveMann!

Thank you for these great answers! I think, with these answers, I slowly understand what UKHeliBob has explained (the lambda function is a little over the top for a newbie like me, but it helps! I got nose bleeding after reading it... :sunglasses: )

I have to stay in the scope of a function if I don't want to use a lambda function for using an object (function) or better I avoid Strings and do char arrays.

In the book, I'm reading right now the author came up with the String object and as a newbie, I thought it was a good idea to use it. But for me, simpler is better at this moment.

henrynoh:
(the lambda function is a little over the top for a newbie like me, but it helps! I got nose bleeding after reading it... :sunglasses: )

As do most of us. In the years I have been using Arduino I have only used a lambda function once.

henrynoh:
In the book, I'm reading right now the author came up with the String object and as a newbie, I thought it was a good idea to use it. But for me, simpler is better at this moment.

String objects are easier to work with, which is why most "learning Arduino" books use them. You won't find it in any C++ book because (I think) the String object is unique to Arduino. Strings are fine if blinking an LED is about all you will ever do with Arduinos, but if you are going to put it to use in a long-term project, such as home IOT, using Strings will eventually crash your Arduino. So, do yourself a favor and just don't use Strings from the beginning.

In fact, if you take the example sketches that use Strings in the book and rewrite them to use char arrays, you will learn a lot of good programming skills.

(Side note- it frosts me to find library files written using delay() and String objects.)

if you’ve ever used ESPAsyncWebServer you might have been using lambdas as this is how examples are written for the callbacks.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.