Issue #11734 has been updated by Hans Mackowiak.


Yurko Bregey wrote:
> 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 ==
> ~~~

you might did something wrong because on "ruby 2.3.0dev (2015-11-25 trunk 52749) [x86_64-linux]" it doesn't show any warning for me

----------------------------------------
Feature #11734: Improved ternary operator
https://bugs.ruby-lang.org/issues/11734#change-55086

* 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/