I started the challenge by going to do a google search on how you define an array-returning function in c++, and according to this link https://www.tutorialspoint.com/cplusplus/cpp_return_arrays_from_functions.htm
that wouldn’t be possible or easy with the knowledge I have.
I’m guessing the TArray is specific to Unreal and that’s why we can return arrays?
I end up using this code at the beginning of the exercise
TArray<FString> ValidWords;
for (int32 Index = 0; Index < 10; Index++)
{
if (GetValidWords(Words[Index]))
{
ValidWords.Emplace(Words[Index]);
}
}
for (int32 Index = 0; Index < ValidWords.Num(); Index++)
{
PrintLine(TEXT("%s"),*ValidWords[Index]);
}
and after, at the end I defined the GetValidWords function as a boolean like this
bool UBullCowCartridge::GetValidWords(FString WordToCheck)
{
if (IsIsogram(WordToCheck) && WordToCheck.Len() >= 4 && WordToCheck.Len() <= 8)
{
return true;
}
else
{
return false;
};
}
This actually worked in my project, I guess this might not be a nice way to do it though. Do you have any thoughts about why this would be not a good way of doing it compared to the way it’s done in the course?