From: patrick@... Date: 2014-07-10T16:28:23+00:00 Subject: [ruby-core:63636] [ruby-trunk - Bug #10024] Array injection of ternary operators injects boolean rather than ternary result Issue #10024 has been updated by Patrick Metcalfe. The #<< has a higher precedence than the ternery operator. ---------------------------------------- Bug #10024: Array injection of ternary operators injects boolean rather than ternary result https://bugs.ruby-lang.org/issues/10024#change-47687 * Author: Blaine Kasten * Status: Open * Priority: Normal * Assignee: * Category: * Target version: * ruby -v: 2.1.2 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- The following code: a = [] a << ''.blank? ? 'blank' : 'not blank' puts a renders [true]. I would expect it to render ['blank'] If I wrap it in parenthesis it does work. a = [] a << ( ''.blank? ? 'blank' : 'not blank' ) puts a # ['blank'] it seems like the logic internally is perceiving this function as: (a << ''.blank?) ? 'blank' : 'not blank' Which seems illogical. -- https://bugs.ruby-lang.org/