Range based Loop in IsIsogram

I just wanted to share an example of how the range based loop can be used for IsIsogram function(although this uses another type of collection, not covered in the BullCows section):

bool UBullCowCartridge::IsIsogram(const FString& Word) const
{

TSet<char16_t> Letters;

for(auto Character : Word)
{
    if(Letters.Contains(Character))
        return false;

    Letters.Add(Character);
}
return true;

}

4 Likes

I love this! I am glad you posted this!

Privacy & Terms