I know there’s a bunch of related questions but I only have one line returning from this method and can’t see why the return line would be unreachable:
public List<int> GetMiddleLaneForAI(Room r)
{
int laneCount = GetLaneCount(true);
List<int> matches = new List<int>();
for(int x = 0; 0 < 5; x++)
{
if(aiCardFrames[x].deployedCard == null)
{
if (laneCount < 3)
{
matches.Add(x);
} else
{
if (x > 0 && x < 4)
{
if (aiCardFrames[x - 1] != null && aiCardFrames[x - 1] != null) matches.Add(x);
}
}
}
}
return matches.Count > 0 ? matches : null; // unreachable code detected
}
>Solution :
Look closely at this line:
for(int x = 0; 0 < 5; x++)
When does this for loop exit? 😉