3 ms·
Well, no, you can do stupid code like: if(g++) { //do something } Which obviously will do something if g was non-zero before incrementing it by one. It's a
by gambiting 9y ago
Well, no, you can do stupid code like:
if(g++)
{
//do something
}
Which obviously will do something if g was non-zero before incrementing it by one. It's a really poor way of writing code, but I have seen it done.
- YSFEJ4SWJUVU6 9y agoFirst of all, I don't agree that code like that is stupid regardless of circumstances. Any programmer worth his salt understands that condition perfectly well without having to think about it. However, it's an altogether different situation to the one I wrote about, given that the value of the incrementing expression is specifically used in that case.
- chrisseaton 9y agoThey said 'if you're not using the value', and you've presented an example where they are using the value, so you're criticism doesn't apply in the case they're talking about.