[ruby-core:96493] [Ruby master Feature#16451] Special ternary operator for methods ending in `?`
From:
nobu@...
Date:
2019-12-26 08:09:27 UTC
List:
ruby-core #96493
Issue #16451 has been updated by nobu (Nobuyoshi Nakada). A method ends with `?` also can take argument(s), so the proposed syntax introduces an ambiguity which doesn't seem solvable. ---------------------------------------- Feature #16451: Special ternary operator for methods ending in `?` https://bugs.ruby-lang.org/issues/16451#change-83424 * Author: myxoh (Nicolas Klein) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- When a method ends in `?`, we should be able to skip the `?` in the ternary operator. For example, we should be able to do: ```ruby question_method? true_statement : false_statement ``` This shouldn't interfere with implementations, as it currently fails to parse. Below are examples: ```ruby def normal_method; true end def question_method?; false end question_method? ? 'was true' : 'was false' # => 'was false' question_method? 'was true' : 'was false' # => 'was false' normal_method ? 'was true' : 'was false' # => 'was true' ``` -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>