ios - In swift, why true && false = 16? -


this question has answer here:

when exec code, c = 16, why ?

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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -