I got it without watching the solution, and I learned something about "else"

I figured out how to do this without watching the solution. (still haven’t watched it)

bool FBullCowGame::IsLowerCase(FString Word) const
{
TMap<char, bool> LetterLowerCase;
for (auto Letter : Word)
{
if(Letter != tolower(Letter))
{
return false;
}
else { }
}
return true;
}

I learned that we don’t have to have anything inside of the “else brackets” I was having trouble because I kept telling it to return true, but when I did, it would only check if the first letter is lowercase. So once I made the “else” blank, the function works properly.

Maybe you’ve figured this out by now, but you don’t even need an else clause!

For example:

bool FalseIfHasA(FString Word)
{
    for (auto& Letter : Word)
    {
        if (letter != 'A')
        {
            return false;
        }
    }
    return true;
}

Privacy & Terms