and

Syntax expression1 and expression2

expression1 && expression2

Action The logical conjunction (boolean "and") operator, yields the boolean value true if both expression1 and expression2 evaluate to true, false otherwise.

Examples file.exists ("myFile") and (!file.exists ("myFile"))

   » false

This expression always evaluates to false, because it is impossible for both expressions to be true at the same time.

file.exists ("myFile") and (file.type ("myFile") == 'TEXT')

   » true

This expression evaluates to true if "myFile" exists and is a text file.

Notes There is no difference between the two forms, && and and.

UserTalk employs "short-circuit" evaluation of boolean expressions. In other words, if expression1 of an and operation evaluates to false, expression2 will not be evaluated, since it can already be determined that the result of the operation will be

false. In example #2 above, the call to file.type will never be made if file.exists returns false (i.e., the file doesn't exist).

See Also or

not

Discuss