From b80df6e8e0a59207545822d92c0a4f78cd64ef5e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 20 Sep 2019 02:32:50 +0900 Subject: [PATCH] Update NEWS and documents [ci skip] [Feature #11297] [Feature #16123] --- NEWS | 3 +++ doc/syntax/assignment.rdoc | 3 ++- doc/syntax/modules_and_classes.rdoc | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index fce2ade06b..ac227110de 100644 --- a/NEWS +++ b/NEWS @@ -77,6 +77,9 @@ sufficient information, see the ChangeLog file or Redmine # .bar .baz # => foo.baz +* Calling a private method with a literal self. as the receiver + is now allowed. [Feature #11297] [Feature #16123] + === Core classes updates (outstanding ones only) Complex:: diff --git a/doc/syntax/assignment.rdoc b/doc/syntax/assignment.rdoc index 7361b7d3bd..91d5d5bba4 100644 --- a/doc/syntax/assignment.rdoc +++ b/doc/syntax/assignment.rdoc @@ -93,7 +93,8 @@ be cached. To call the method, use self.big_calculation. You can force a method call by using empty argument parentheses as shown above or by using an explicit receiver like self.. Using an explicit -receiver may raise a NameError if the method's visibility is not public. +receiver may raise a NameError if the method's visibility is not public or the +receiver is the literal self. Another commonly confusing case is when using a modifier +if+: diff --git a/doc/syntax/modules_and_classes.rdoc b/doc/syntax/modules_and_classes.rdoc index dd70d4ac21..8fc84d522a 100644 --- a/doc/syntax/modules_and_classes.rdoc +++ b/doc/syntax/modules_and_classes.rdoc @@ -191,8 +191,8 @@ Here is an example: a.n b # raises NoMethodError A is not a subclass of B The third visibility is +private+. A private method may not be called with a -receiver, not even +self+. If a private method is called with a receiver a -NoMethodError will be raised. +receiver, not even if it equals +self+. If a private method is called with a +receiver other than a literal +self+ a NoMethodError will be raised. === +alias+ and +undef+