Merge pull request #368 from brentguf/logical-operators
Logical operators
This commit is contained in:
commit
90b1a2b4b5
1 changed files with 4 additions and 4 deletions
|
@ -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:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue