Hi,
I would like to extend the String.startsWith() with a varaible number of arguments, so that instead of having to call the function n x times, I can just do something like
bool result = myString.startsWith("aa", "bb", "cc", "dd", ... etc );
Could this be done?
Thanks in advance for any hint!
If you have access to the source code of the String class, sure, just add your functions.
Updates will probably overwrite your changes, beware.
I would not go through all the trouble extending the String class itself,
a subclass of String, or a non-member function, could also work.
On 8 bit Arduinos I avoid using String,
No need to extend the existing function
Write a function of your own that takes an array of arguments and a target String. Within the function iterate through the array and use the startsWith() function to test the target String against each element of the array
1 Like
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.