and |
Type | operator |
Dictionary | LCS |
Library | LiveCode Script |
Syntax | <leftValue> and <rightValue>
|
Summary | Allows the construction of compound boolean expressions, which evaluate to true
if both operands are true, false otherwise.
|
Introduced | 1.0 |
OS | mac, windows, linux, ios, android, web |
Platforms | desktop, server, mobile |
Parameters | Name | Type | Description |
---|
leftValue | | leftValue is true or false, or an expression that evaluates to
true or false.
|
rightValue | | rightValue is true or false, or an expression that evaluates to
true or false.
|
|
Example | put (1 > 0) and (1 = 0)
put (1 > 0) and (1 = 1) and (0 = 0)
local myCount
if the shiftKey is down and myCount > 1 then exit mouseUp
|
Related | Operator: bitAnd, not, or
Constant: false, true
Function: asin, value
Glossary: argument, boolean, evaluate, execution error, expression, function, logical, operand, operation, operator, value
|
Description | Use the and operator to combine two or more logical
values into a compound boolean expression.
If leftValue is false or rightValue is false, or if both leftValue and
rightValue are false, then the and operation evaluates to
false. If leftValue and rightValue are both true, the expression leftValue
and rightValue evaluates to true. In an expression with more
than two operands, there is an implicit grouping of the first pair,
so that the first pair is evaluated first, then subsequent values
are evaluated. If any of the operands evaluates to false,
the entire expression evaluates to false. You can combine
the logical operators and, or, and not
in an expression.
Note: LiveCode uses what is known as "short-circuit evaluation" for
logical operators. This means that leftValue is
evaluated first. If leftValue is false, the expression
leftValue and rightValue is false regardless of what rightValue is (because the
expression evaluates to false unless both the values are
true). In this case, LiveCode does not evaluate rightValue, since
doing so is not necessary to determine the value of leftValue
or rightValue. For example, evaluating the expression asin(2) normally
causes an execution error (because 2 is not a legal argument for the
arc sine function), but evaluating the expression
(1 = 0) and (asin(2) = 1) does not cause an error: since (1 = 0) is
always false, the whole statement is always false and LiveCode never tries
to evaluate the asin function.
|
Tags | math |