Suggestion for Swift Document (3

(Sorry,don't know if it's appropriate to make an opinion.)
The Document
According to the literal meaning of the document, especially influenced by this sample code, it is easy to cause a misunderstanding and make the reader think that && and || it is a combination of the same level right.


Anyone who is proficient in programming probably knows that Swift's three logical operators are combined in the following order: not > and > or.But for the average reader, this can be confusing.

Later, I made a script to figure out the order of the combinations.

let T = true
let F = false

print(T || F && T)  // true
print(T || F && F)  // true
print(T && F || T)  // true
print(T && F || F)  // false

After a while, I think the misunderstanding may be because the example given is too coincidental. Perhaps the order of processing should be described under the heading Logical Operations.

1 Like

You can also file an issue against the GitHub repository that hosts the Swift book:

2 Likes

Thanks.

1 Like