Issue #14397 has been updated by Eregon (Benoit Daloze).


Would it be simpler for the semantics to always return an Array of symbols?
Otherwise `final` (and other potential uses) has to handle both a single Symbol and an Array of Symbol.

One concern is the extra allocations for the common case of a single argument given to `private`.

----------------------------------------
Feature #14397: public, protected and private should return their arguments instead of self
https://bugs.ruby-lang.org/issues/14397#change-69828

* Author: usa (Usaku NAKAMURA)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 2.6
----------------------------------------
Matsuda-san suggested me that `public`, `protected` and `private` should return their arguments instead of `self`,
to write such code:`

```Ruby
require "finalist"
# see https://github.com/joker1007/finalist

class Foo
  extend Finalist

  final private def foo
  end
end
```

I believe that it's reasonable request, and also believe that there is no product code which uses the return values of `public`, `protected` and `private`.
Matz, how do you think about this change?
The patch is attached.


---Files--------------------------------
return_values_of_visibility_methods.diff (7.47 KB)


-- 
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>