We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My point is the use of ternary conditional operator does not provide any value other than bragadacio. The simplest code compiles cleaner with only 3 jump instructions. The ternary code requires 13 jump instructions. Best case scenario through the ternary code is 7 jump instructions. Best/Worst case for the first code is 3 jump instructions.
But, more importantly if you had to revise the original code to compare 5 integers instead of 4, it's easier to revise the first example. You just need to add another if statement. To revise the ternary conditional, you would have dig through the conditional and update each level of comparison with another && new condition. If you miss one, then you have a logic bug.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Functions
You are viewing a single comment's thread. Return to all comments →
My point is the use of ternary conditional operator does not provide any value other than bragadacio. The simplest code compiles cleaner with only 3 jump instructions. The ternary code requires 13 jump instructions. Best case scenario through the ternary code is 7 jump instructions. Best/Worst case for the first code is 3 jump instructions.
But, more importantly if you had to revise the original code to compare 5 integers instead of 4, it's easier to revise the first example. You just need to add another if statement. To revise the ternary conditional, you would have dig through the conditional and update each level of comparison with another && new condition. If you miss one, then you have a logic bug.