E's booleans are as you'd expect. There are only two boolean values, known as "true" and "false". Here are the applicable operators in precedence order. Logical Or (don't-care-associative)
Evaluates left to right until it finds a true condition. If any are true, it returns true and stops evaluating. If all return false, then all are evaluated and the result is false. Logical And (don't-care-associative)
Evaluates left to right until it finds a false condition. If any are false, it returns false and stops evaluating. If all return true, then all are evaluated and the result is true. Boolean Comparisons (non-associative)
Whereas "&&" and "||" are flow control operators as well as logical operators, "&","|",and "^" are normal operators that always evaluate both their operands. Unary Expressions (left associative)
As you'd expect.
Additional boolean MessagesIn addition to the messages corresponding to the above operators, booleans respond to the pick(trueChoice, falseChoice) message. ? pragma.syntax("0.8") ? true.pick(3, 5) # value: 3 ? false.pick(3, 5) # value: 5 In response to the pick message, true will return the trueChoice, and
false will return the falseChoice.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Unless stated otherwise, all text on this page which is either unattributed or by Mark S. Miller is hereby placed in the public domain.
|