Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now
4 added 1 characters in body
source | link

I'm not sure in C#, but in C++ it's legal to assign value inside a if statement.

Writing the if this way prevent you from bad surprises if one forgets one character: something like if ( customer.Age = 15).

When inversing rhs and lhs it's not possible to assign customer.Age to the value 515 which is const.

So, probably the code you're reading was written by a former C++ folk.

But as MS Visual has warning for assignment inside ifs, I tend to never to write them this way.

I'm not sure in C#, but in C++ it's legal to assign value inside a if statement.

Writing the if this way prevent you from bad surprises if one forgets one character: something like if ( customer.Age = 15).

When inversing rhs and lhs it's not possible to assign customer.Age to the value 5 which is const.

So, probably the code you're reading was written by a former C++ folk.

But as MS Visual has warning for assignment inside ifs, I tend never to write them this way.

I'm not sure in C#, but in C++ it's legal to assign value inside a if statement.

Writing the if this way prevent you from bad surprises if one forgets one character: something like if ( customer.Age = 15).

When inversing rhs and lhs it's not possible to assign customer.Age to the value 15 which is const.

So, probably the code you're reading was written by a former C++ folk.

But as MS Visual has warning for assignment inside ifs, I tend to never to write them this way.

3 deleted 26 characters in body
source | link

I'm not sure in C#, I don't think it's legal, but in C++ it's legal to assign value inside a if statement.

Writing the if this way prevent you from bad surprises if one forgets one character: something like if ( customer.Age = 15).

When inversing rhs and lhs it's not possible to assign customer.Age to the value 5 which is const.

So, probably the code you're reading was written by a former C++ folk.

But as MS Visual has warning for assignment inside ifs, I tend never to write them this way.

I'm not sure in C#, I don't think it's legal, but in C++ it's legal to assign value inside a if statement.

Writing the if this way prevent you from bad surprises if one forgets one character: something like if ( customer.Age = 15).

When inversing rhs and lhs it's not possible to assign customer.Age to the value 5 which is const.

So, probably the code you're reading was written by a former C++ folk.

But as MS Visual has warning for assignment inside ifs, I tend never to write them this way.

I'm not sure in C#, but in C++ it's legal to assign value inside a if statement.

Writing the if this way prevent you from bad surprises if one forgets one character: something like if ( customer.Age = 15).

When inversing rhs and lhs it's not possible to assign customer.Age to the value 5 which is const.

So, probably the code you're reading was written by a former C++ folk.

But as MS Visual has warning for assignment inside ifs, I tend never to write them this way.

2 added 56 characters in body
source | link

I'm not sure in C#, I don't think it's legal, but in C++ it's legal to assign value inside a if statement.

Writing the if this way prevent you from bad surprises if one forgets one character: something like if ( customer.NameAge = ""15).

When inversing rhs and lhs it's not possible to assign customer.NameAge to the value ""5 which is const.

So, probably the code you're reading was written by a former C++ folk.

But as MS Visual has warning for assignment inside ifs, I tend never to write them this way.

I'm not sure in C#, I don't think it's legal, but in C++ it's legal to assign value inside a if statement.

Writing the if this way prevent you from bad surprises if one forgets one character: something like if ( customer.Name = "")

When inversing rhs and lhs it's not possible to assign customer.Name to the value "" which is const.

So, probably the code you're reading was written by a former C++ folk.

But as MS Visual has warning for assignment inside ifs, I tend never to write them this way.

I'm not sure in C#, I don't think it's legal, but in C++ it's legal to assign value inside a if statement.

Writing the if this way prevent you from bad surprises if one forgets one character: something like if ( customer.Age = 15).

When inversing rhs and lhs it's not possible to assign customer.Age to the value 5 which is const.

So, probably the code you're reading was written by a former C++ folk.

But as MS Visual has warning for assignment inside ifs, I tend never to write them this way.

1
source | link