ios - In swift, why true && false = 16? -
this question has answer here:
i have seen swift spec, says
the logical , operator (
a && b
) creates logical expressions both values must true overall expression true.
if either value false, overall expression false. in fact, if first value false, second value won’t evaluated, because can’t possibly make overall expression equate true. known short-circuit evaluation.
this example considers 2 bool values , allows access if both values true:
let entereddoorcode = true let passedretinascan = false if entereddoorcode && passedretinascan { println("welcome!") } else { println("access denied") } // prints "access denied"
it has nothing problem, bug ?
you hit breakpoint before line evaluated (at least screenshot suggests so). go 1 step further down , you'll see c
become false
expected.
at point in time, c
points random location in memory happens interpreted 16
debugger.
Comments
Post a Comment