ruby-changes:45302
From: naruse <ko1@a...>
Date: Thu, 19 Jan 2017 18:34:35 +0900 (JST)
Subject: [ruby-changes:45302] naruse:r57375 (trunk): More description about the protected attribute of a method
naruse 2017-01-19 18:34:30 +0900 (Thu, 19 Jan 2017) New Revision: 57375 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57375 Log: More description about the protected attribute of a method Modified files: trunk/vm_method.c Index: vm_method.c =================================================================== --- vm_method.c (revision 57374) +++ vm_method.c (revision 57375) @@ -1669,6 +1669,15 @@ rb_mod_public(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1669 * defined methods to protected. With arguments, sets the named methods * to have protected visibility. * String arguments are converted to symbols. + * + * If a method has protected visibility, it is callable only where + * <code>self</code> of the context is the same as the method. + * (method definition or instance_eval). This behavior is different from + * Java's protected method. Usually <code>private</code> should be used. + * + * Note that a protected method is slow because it can't use inline cache. + * + * To show a private method on RDoc, use <code>:doc:</code> instead of this. */ static VALUE @@ -1696,6 +1705,8 @@ rb_mod_protected(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1705 * private :a * end * Mod.private_instance_methods #=> [:a, :c] + * + * Note that to show a private method on RDoc, use <code>:doc:</code>. */ static VALUE -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/