From: 6ftdan@... Date: 2015-11-24T20:28:54+00:00 Subject: [ruby-core:71662] [Ruby trunk - Feature #11734] Improved ternary operator Issue #11734 has been updated by Daniel P. Clark. `&` is associated more with proc. I think `_` would be closer to the kind of thing you're looking for. ~~~ruby some_long_expression = :baz _ ? _.to_s : 'foobar' # => "baz" ~~~ Although I tried in-lining it with a semicolon and found that the `_` feature only works off of the previous' lines results. So the following won't work. ~~~ruby :baz; _ ? _.to_s : 'foobar' # => "foobar" ~~~ And this doesn't work ~~~ruby x = 4 :fiz ? _.to_s : 'foobar' # => "4" ~~~ So if you don't mind putting your ternary operation on the next line you can just use `_` ---------------------------------------- Feature #11734: Improved ternary operator https://bugs.ruby-lang.org/issues/11734#change-55065 * 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/