From: shevegen@... Date: 2019-12-25T16:37:25+00:00 Subject: [ruby-core:96471] [Ruby master Feature#16451] Special terniary operators for methods ending in `?` Issue #16451 has been updated by shevegen (Robert A. Heiler). I am slightly against this proposal. To me personally it does not make a lot of sense to differ between the trailing character of a method in regards to the ternary operator. IMO the ternary operator should not discriminate against last characters of any method, ever. It would also add a bit more complexity and I am not sure if the trade-off is worth to be had here. Another problem I see is the prolific use of '?'. It would be better, in my opinion, to keep the syntax simple(r), if possible. With many special syntax and combinations of syntax in use, it becomes harder to determine what is going on in general. Ultimately you only have to convince matz about the use case and proposed benefit of a suggestion, though, not me. :) (I should also add that I use the trailing token '?' for methods a LOT, but I avoid using the ternary operator, largely because I have found that it takes me longer to determine what is going on, as opposed to e. g. if/else checks, even though they require more lines of code.) ---------------------------------------- Feature #16451: Special terniary operators for methods ending in `?` https://bugs.ruby-lang.org/issues/16451#change-83398 * 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: