From: matz@... Date: 2015-07-28T07:42:28+00:00 Subject: [ruby-core:70145] [Ruby trunk - Feature #11297] Allow private method of self to be called Issue #11297 has been updated by Yukihiro Matsumoto. It changes the concept of private methods a little. It's OK to merge the patch if the document is updated at the same time.. Matz. ---------------------------------------- Feature #11297: Allow private method of self to be called https://bugs.ruby-lang.org/issues/11297#change-53575 * Author: Soutaro Matsumoto * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Ruby does not allow private method to be called if receiver is given. Calling private method with receiver is prohibited even if it is written as self, though the fact that the receiver is self is still clear. This ticket is to propose to allow the private method to be called if its receiver is written as self. The following Ruby program is to explain my idea. ~~~ class A private def f end end A.new.instance_eval do f() # Okay, without receiver self.f # Currently NoMethodError, but should be okay in my opinion self.itself.f # NoMethodError anyway; the receiver is not written as self end ~~~ This change will allow to call private accessor method like self.title=. It also will make refactoring to make a public method private easier. Currently, such kind of refactoring may require to rename duplicated local variables or add () to method calls. ---Files-------------------------------- private_with_self.diff (916 Bytes) -- https://bugs.ruby-lang.org/