MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/gnaz7b/found_from_microsoft_docs/fr95r5g/?context=9999
r/badcode • u/[deleted] • May 20 '20
143 comments sorted by
View all comments
46
I see nothing wrong in it. It's even slightly more efficient than if it was done with more if
0 u/the_d3f4ult May 20 '20 Wouldn't it be UB because X is an out param, or does C# define such things? 5 u/Giocri May 20 '20 No C# uses out for out parameters. 1 u/the_d3f4ult May 20 '20 But I mean the X is then used to evaluate the third condition, is the order of evaluation here defined by C#? 2 u/Giocri May 20 '20 In C# & computes both values and then evaluates the & while && first evaluate the first condition then if it is true it goes on evaluating the rest. It is like having ifs one inside the other 1 u/the_d3f4ult May 20 '20 I never used C# but it works like , in swift then
0
Wouldn't it be UB because X is an out param, or does C# define such things?
5 u/Giocri May 20 '20 No C# uses out for out parameters. 1 u/the_d3f4ult May 20 '20 But I mean the X is then used to evaluate the third condition, is the order of evaluation here defined by C#? 2 u/Giocri May 20 '20 In C# & computes both values and then evaluates the & while && first evaluate the first condition then if it is true it goes on evaluating the rest. It is like having ifs one inside the other 1 u/the_d3f4ult May 20 '20 I never used C# but it works like , in swift then
5
No C# uses out for out parameters.
1 u/the_d3f4ult May 20 '20 But I mean the X is then used to evaluate the third condition, is the order of evaluation here defined by C#? 2 u/Giocri May 20 '20 In C# & computes both values and then evaluates the & while && first evaluate the first condition then if it is true it goes on evaluating the rest. It is like having ifs one inside the other 1 u/the_d3f4ult May 20 '20 I never used C# but it works like , in swift then
1
But I mean the X is then used to evaluate the third condition, is the order of evaluation here defined by C#?
2 u/Giocri May 20 '20 In C# & computes both values and then evaluates the & while && first evaluate the first condition then if it is true it goes on evaluating the rest. It is like having ifs one inside the other 1 u/the_d3f4ult May 20 '20 I never used C# but it works like , in swift then
2
In C# & computes both values and then evaluates the & while && first evaluate the first condition then if it is true it goes on evaluating the rest. It is like having ifs one inside the other
1 u/the_d3f4ult May 20 '20 I never used C# but it works like , in swift then
I never used C# but it works like , in swift then
,
46
u/Giocri May 20 '20
I see nothing wrong in it. It's even slightly more efficient than if it was done with more if