Merge pull request #368 from brentguf/logical-operators

Logical operators
This commit is contained in:
Ilya Kantor 2018-03-03 09:19:56 +03:00 committed by GitHub
commit 90b1a2b4b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,11 +76,11 @@ Given multiple OR'ed values:
result = value1 || value2 || value3;
```
The OR `"||"` operator does the following:
The OR `||` operator does the following:
- Evaluate operands from left to right.
- For each operand, convert it to boolean. If the result is `true`, then stop and return the original value of that operand.
- If all other operands have been assessed (i.e. all were `falsy`), return the last operand.
- If all other operands have been assessed (i.e. all were `false`), return the last operand.
A value is returned in its original form, without the conversion.
@ -194,7 +194,7 @@ Given multiple AND'ed values:
result = value1 && value2 && value3;
```
The AND `"&&"` operator does the following:
The AND `&&` operator does the following:
- Evaluate operands from left to right.
- For each operand, convert it to a boolean. If the result is `false`, stop and return the original value of that operand.
@ -268,7 +268,7 @@ So it is recommended to use every construct for its purpose. Use `if` if we want
## ! (NOT)
The boolean NOT operator is represented with an exclamation sign `"!"`.
The boolean NOT operator is represented with an exclamation sign `!`.
The syntax is pretty simple: