[ruby-core:96470] [Ruby master Feature#16451] Special terniary operators for methods ending in `?`
[email protected] Wed, 25 Dec 2019 15:46:25 +0000 (UTC)
| Newsgroups | gmane.comp.lang.ruby.core |
|---|---|
| Message-ID | <redmine.issue-16451.20191225154624.b3aa5ec3c07bed80@ruby-lang.org> |
Issue #16451 has been reported by myxoh (Nicolas Klein). ---------------------------------------- Feature #16451: Special terniary operators for methods ending in `?` https://bugs.ruby-lang.org/issues/16451 * Author: myxoh (Nicolas Klein) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- **Feature proposal** When a method ends in `?` we should be able to skip the `?` in the ternary operator So for example you'd be able to do `question_method? true_statement : false_statement` This shouldn't interfere with implementations as currently this fails to parse. ``` def normal_method true end ``` ``` def question_method? false end ``` Ternary operator: ``` question_method? 'was true' : 'was false' => 'was false' normal_method? 'was true' : 'was false' => method not found normal_method? normal_method ? 'was true' : 'was false' => 'was true' ``` and finally to preserve currently compatibility ``` question_method? ? 'was true' : 'was false' => 'was true' ``` -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>