Thanks for sharing. My lowercase check was the same as yours. I haven’t checked Ben’s solution yet, but I think his hints naturally lead us to this solution. I’m not sure why he’s suggested we deal with the escape character ‘\0’ though. Excited to find out why! I’ve commented it out for me and didn’t notice any ill effects… It does seem good practice to at least think about how your function might be misused though. A person could spend all day coding defensively right?
I’ve just checked Ben’s solution, and finally noticed the subtle difference of your use of isLower! I’m checking it twice for no reason.
I didn’t notice any difference when testing for the escape character as shown though. Ctrl + @ didn’t seem to do anything visible, and when I checked the debugger I hadn’t managed to capture the character that way. But I’ll not linger on that, I have more learning to do…
A person could spend all day coding defensively right?
Polish and testing is also always a good thing and solves both hackers misusing input fields and a bad experience for users from poor input validation checks. So not necessarily defensive coding.