weird results with IF

The reason for this result can be found in documentation of function strtol which is used first on using the comparison operators EQU, NEQ, LSS, LEQ, GTR, GEQ as explained in my answer on Symbol equivalent to NEQ, LSS, GTR, etc. in Windows batch files. Return Value On success, the function returns the converted integral … Read more

VB6 IIf advantage

IIf is not an operator or a language construct, it’s a function, just like any other function such as Left. It will therefore evaluate all its arguments at all times, whereas with If you will only evaluate the correct branch. Example: denominator = 0 value = IIf(denominator = 0, 0, value / denominator) This will … Read more

How is Swift `if let` evaluated?

Essentially the line is saying, “if you can let the new variable name equal the non-optional version of optionalName, do the following with it”. As Martin pointed out, this is called Optional Binding. The sole purpose of it is to test if an optional variable contains an actual value and bind the non-optional form to … Read more

Can I use the range operator with if statement in Swift?

You can use the “pattern-match” operator ~=: if 200 … 299 ~= statusCode { print(“success”) } Or a switch-statement with an expression pattern (which uses the pattern-match operator internally): switch statusCode { case 200 … 299: print(“success”) default: print(“failure”) } Note that ..< denotes a range that omits the upper value, so you probably want … Read more