MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/oul365/from_the_codebase_that_brought_you_stdstring_comma/h74r81q/
r/badcode • u/uruharushia • Jul 30 '21
84 comments sorted by
View all comments
Show parent comment
3
Ok cool, i totally took for granted we were talking about integers
Now it makes sense 👍🏻
3 u/MorphTheMoth Jul 31 '21 you can do in with integers too, dont know why you would but this works:int a = 0; if( (a=2) == 2 ) // true 2 u/[deleted] Jul 31 '21 Well technically the truth but in this case you need to actively add parentheses which kind of removes the "by mistake" aspect 1 u/MorphTheMoth Jul 31 '21 oh right, the c# compiler gives an error if you implicitly cast an int into a bool
you can do in with integers too, dont know why you would but this works:
int a = 0; if( (a=2) == 2 ) // true
2 u/[deleted] Jul 31 '21 Well technically the truth but in this case you need to actively add parentheses which kind of removes the "by mistake" aspect 1 u/MorphTheMoth Jul 31 '21 oh right, the c# compiler gives an error if you implicitly cast an int into a bool
2
Well technically the truth but in this case you need to actively add parentheses which kind of removes the "by mistake" aspect
1 u/MorphTheMoth Jul 31 '21 oh right, the c# compiler gives an error if you implicitly cast an int into a bool
1
oh right, the c# compiler gives an error if you implicitly cast an int into a bool
View all comments
Show parent comment
3
u/[deleted] Jul 30 '21
Ok cool, i totally took for granted we were talking about integers
Now it makes sense 👍🏻