Logic Quiz
What does "cat" >= "dog" return?
"cat"truefalse"cat" is alphabetically less than (prior to)"dog"; therefore, the operation returns false. Both operands are strings, so the comparison is valid.What does "cat" != [] return?
"cat"truefalse"cat" does not equal an empty array; therefore, the operation returns true. One can check for equality across data types, so the comparison is valid.What does [] < [true] return?
"cat"truefalseWhat does 2 < 3 && 2.even? return?
truefalse2 < 3 and 2.even? are true (both expressions evaluate to true), the statement returns true.What does 2.odd? && 2 < 3 return?
truefalse2.odd? evaluates to false, and the operator is &&, the statement short-circuits and returns false regardless of the second operand.What does 2.odd? || 2 < 3 return?
truefalse2.odd? evaluates to false, and the operator is ||, the Ruby interpreter does not short-circuit and evaluates the second operand. Because 2 < 3 evaluates to true, the statement returns true.