M
mzdude
I have no interest in starting a religious war on the subject, but
I've
been doing some code reviews and running across code like
Method 1:
int x;
if( 0 == ( x = MyFunct() ) )
// do something
I personally don't like the style. I seem to remember there were
reasons not to do this but
today google is not my friend. I can't find any reasons against this.
Are there valid reasons
not to do this style?
I would prefer
Method 2:
const int x = MyFunct();
if( 0 == x )
// do something
reasons for method 2
1) declare and initialize
2) allows variable to be const
Are they any valid reasons to not do method 1?
I've
been doing some code reviews and running across code like
Method 1:
int x;
if( 0 == ( x = MyFunct() ) )
// do something
I personally don't like the style. I seem to remember there were
reasons not to do this but
today google is not my friend. I can't find any reasons against this.
Are there valid reasons
not to do this style?
I would prefer
Method 2:
const int x = MyFunct();
if( 0 == x )
// do something
reasons for method 2
1) declare and initialize
2) allows variable to be const
Are they any valid reasons to not do method 1?