I coming back to C# programming after some years of HTML/ASP. I came across these lines and cannot find what it does. It is a method in a class:
private string PeekNext()
{
if (pos < 0)
// pos < 0 indicates that there are no more tokens
return null;
if (pos < tokens.Length)
{
if (tokens[pos].Length == 0)
{
++pos;
return PeekNext();
}
return tokens[pos];
}
string line = reader.ReadLine();
if (line == null)
{
// There is no more data to read
pos = -1;
return null;
}
// Split the line that was read on white space characters
tokens = line.Split(null);
pos = 0;
return PeekNext();
}
Is it calling itself until some of the other Returns happens?
What is happening here, never seen a method returning itself!? What is Returned, empty string or what...? Or maybe I just missed it before.
Maybe simple but puzzles me.