forked from sharpsaw/pry-docmore
-
Notifications
You must be signed in to change notification settings - Fork 1
Ruby Keyword: and
☈king edited this page Nov 19, 2012
·
4 revisions
Boolean conjunction.
Only evaluates to true
if both its left and right side are true.
Remember that the 'and' operator is lower precedence operator than '&&', so
an_expression and another_expression is roughly equivalent to: (an_expression) && (another_expression)
Truth table
true and true ⇒ true false and true ⇒ false false and false ⇒ false
Precedence
true and not false ⇒ true true && not false ⇒ SyntaxError a = true and false; a ⇒ true a = true && false; a ⇒ false
The fowl chain
if false or true && false then false elsif true and false or true then true end ⇒ true
See http://phrogz.net/ProgrammingRuby/language.html#table_18.4