Project

General

Profile

Feature #17938

Updated by matheusrich (Matheus Richard) over 3 years ago

Some Ruby methods accept optional boolean arguments. This kind of os parameter is known to be confusing since you cannot tell just looking at the method call what the parameter mean. For example: 

 ```ruby 
 object.respond_to?(:symbol, false) # what does `false` mean? 
 object.methods(true) # what does `true` mean? 
 ``` 

 Now compare that to 

 ```ruby 
 object.respond_to?(:symbol, include_all: false) # what does `false` mean? 
 object.methods(regular: true) 
 # or 
 object.methods(only_public: true) 
 # or 
 object.methods(include_all: false) 
 ``` 

 I know Matz doesn't like a breaking changes, so maybe we could have both to not break current calls, but allow a nicer syntax in newer Ruby? I don't know the depths of the Ruby C implementation, so here's what I thought in plain Ruby: 

 ```ruby 
 def respond_to?(symbol, include_all_positional=false, include_all: nil) 
   include_all ||= false 

   # ... 
 end 
 ``` 

 I'm willing to tackle this, if approved.

Back