<p>In many languages, assignments are legal in conditions. I never understood the reason behind this. Why would you write:</p>
<pre><code>if (var1 = var2) {
  ...
}
</code></pre>
<p>instead of:</p>
<pre><code>var1 = var2;
if (var1) {
  ...
}
</code></pre>
<p>?</p>

It can be useful if you're calling a function that returns either data to work on or a flag to indicate an error (or that you're done).
Something like:
```
```
while ((c = getchar()) != EOF) {
    // process the character
}

// end of file reached...
```
```
Personally it's an idiom I'm not hugely fond of, but sometimes the alternative is uglier.