Can anyone tell me which version of this code would be better to use?
for(int32 HiddenIndex = 0; HiddenIndex < HiddenWord.Len(); HiddenIndex++)
{
if(Guess[GuessIndex] == HiddenWord[HiddenIndex])
{
CowCount++;
break;
}
}
Or
if(HiddenWord.GetCharArray().Contains(Guess[GuessIndex]))
{
CowCount++;
}
Both achieve the same end result. I’m just curious if the contains method would run through the entire iteration or break out on finds in other words less efficient?