It's disgusting. I have three values that have to be checked, and if any two of them have a >= 2 difference, then I run through some tasks.
I'm attempting to write a deployment script that checks the OS major version, then runs command based on that. I can grab that just fine with [System.Environment]::OSVersion.Version.Major, but when I attempt to use that in an if/elseif statement, I always get the first condition, and somehow the variable changes.
I am unable to understand why following if blocks execute. How the if conditions will be evaluated?&& has higher precedence than || (source). So adding in parens to emphasize how those are being evaluated:
I'm confused on this code what is the difference between the two conditions? Why the results are not the same? Example Number 1 - Don't have the same datatype w/ same value, but it returns the same result of true
I was checking some code, and something similar to the following showed up:It looked the kind of code that could be improved, but I couldn't find a more elegant solution for such a trivial and common conditional statement.