Home On the Range( Range-Based For Loops)

This is the code for the Range-Based For Loop. I was able to catch on quicker than with the TArray, albeit a couple naming issues:

TArray<FString> UBullCowCartridge::GetValidWords(TArray<FString> WordList) const
{
    TArray<FString> ValidWords;'s's


    for (<FString> Word : WordList )
    {
        if (Word.Len() >= 4 && Word.Len() <= 8 && IsIsogram(Word) )
        {
            ValidWords.Emplace(Word);            
        }
    }

My original code had “Word” as Wordlist, since I thought I wanted to place in the Functions “WordList” here. And the Data I was pulling from, in my mind, was from the header file. So I named it “Words”.

It still worked, no issues. But the variable “WordList” had already stored the Words variable from the headerfile HiddenWordList.h. There was no need to call up that collection again, otherwise what is the point of this function?

I suspect the WordsList temporary variable worked because it was not interfering with the functions variable: so indeed it was being used for single words.

I seem to have had a “Get Smart” moment. Not the movie, but the old black and white series. Unlike the recent movie, this agent came up with completely brilliant yet entirely wrong deductions about a crime scene, often using evidence that had nothing to do with the crime, that ended up saving the day . The 90’s “Inspector Gadget” cartoon, voice acted by the original Get Smart actor, is an apt comparison.

I believe you posted this in the wrong place, as this is the Blender Courses area, and I believe your code is for one of the gaming related courses. You should probably post again in the Show category of the gaming class you’re taking, and remove this post.

3 Likes

You are correct. It has been fixed

Privacy & Terms