Why would you use an assignment in a condition?

It’s more useful for loops than if statements.

while( var = GetNext() )
{
  ...do something with var 
}

Which would otherwise have to be written

var = GetNext();
while( var )
{
 ...do something
 var = GetNext();
}

Leave a Comment