[ruby-core:71677] [Ruby trunk - Feature #11734] Improved ternary operator

From: hanmac@...
Date: 2015-11-25 05:10:36 UTC
List: ruby-core #71677
Issue #11734 has been updated by Hans Mackowiak.


@Daniel: _ with previous line result is a feature of IRB and PRY not ruby itself

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

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

In This Thread

Prev Next