"Use of unassigned local variable" error that I don't understand

Unity is protesting. It gives me the error: Use of unassigned local variable `att. It gives the error for the return-line, not for the line in the if-statement.

In some cases like if you have a local variable declaration inside a code-block you can sometimes get this error, but I can’t see how this function can not see the declaration. Anyone have any ideas? What am I not seeing? Thanks!

public cBaseStats GetAttribute(string name)
    {
        int cnt;
        cBaseStats att;
        for (cnt = 0; cnt < _attrib.Length; cnt++)
        {
            if (_attrib[cnt].Name == name)
                att = _attrib[cnt];
        }
        return att;
    }

Never mind, I solved it. I just had to add a ‘null’ or a ‘new’-line to the declaration. Ah, the joys of coding and debugging. You sit sweating there for an hour for a mere triviality. :smile: