Project

General

Profile

Feature #16451

Updated by sawa (Tsuyoshi Sawada) 10 months ago

**Feature proposal** 

 When a method ends in `?`, `?` we should be able to skip the `?` in the ternary operator. For example, we should operator 

 So for example you'd be able to do: do 

 ```ruby 
 question_method? `question_method? true_statement : false_statement 
 ``` false_statement` 

 This shouldn't interfere with implementations, implementations as it currently this fails to parse. Below are examples: 

 ```ruby ``` 
 def normal_method; normal_method 
   true 
 end 
 ``` 

 ``` 
 def question_method?; question_method? 
   false 
 end 
 ``` 

 Ternary operator: 

 ``` 
 question_method? ? 'was true' : 'was false' # 
 => 'was false' 

 normal_method? 'was true' : 'was false' 
 question_method?     => method not found normal_method? 

 normal_method ? 'was true' : 'was false' # 
 => 'was false' true' 
 normal_method ``` 

 and finally to preserve currently compatibility 

 ``` 
 question_method? ?      'was true' : 'was false' # 
 => 'was true' 
 ```

Back