In many languages assignments are legal in conditions. I never understood the reason behind this. Why would you write:
if (var1 = var2) { ... }
instead of:
var1 = var2; if (var1) { ... }
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(); }
1.4m articles
1.4m replys
5 comments
57.0k users