From: bregey@... Date: 2015-11-25T10:06:37+00:00 Subject: [ruby-core:71680] [Ruby trunk - Feature #11734] Improved ternary operator Issue #11734 has been updated by Yurko Bregey. Hans Mackowiak wrote: > why not: > > ```ruby > (x = some_long_expression) ? x.to_s : 'foobar' > ``` think it's not good. Ruby 2.2.3p173 shows warning: ~~~ warning: found = in conditional, should be == ~~~ ---------------------------------------- Feature #11734: Improved ternary operator https://bugs.ruby-lang.org/issues/11734#change-55081 * Author: Yurko Bregey * Status: Open * Priority: Normal * Assignee: ---------------------------------------- In ternary operator it would be nice to be able to pass expression result from *condition* into *value_if_true/value_if_false* in such way: `some_long_expression ? &.to_s : 'foobar'` where `&` refers to `some_long_expression` Instead of doing: `some_long_expression ? some_long_expression.to_s : 'foobar'` or: `result = some_very_very_long_expression result ? result.to_s : 'foobar'` -- https://bugs.ruby-lang.org/