I do not understand why :
false && (1/0==0)
makes an error as && shoud return false immediately without evaluating its 2nd argument.
Is that because the Swift compiler evaluates 1/0==0 at compile time ?
-w
I do not understand why :
false && (1/0==0)
makes an error as && shoud return false immediately without evaluating its 2nd argument.
Is that because the Swift compiler evaluates 1/0==0 at compile time ?
-w
a. What is the error?
b. The second condition is not evaluated, but it's still compiled.
c. It may depend on what your real code is. If you really wrote the sub-expression "1/0", it seems reasonable for the compiler to tell you that's wrong. If you wrote:
let x = …
let y = ...
if x > 0 && y / x == 0 { … }
then there shouldn't be an error message. If you wrote:
let x = 0
let y = ...
if x > 0 && y / x == 0 { … }
then the compiler should tell you that the condition is always false.
Etc.