ruby-changes:64310
From: Rados=C5=82aw <ko1@a...>
Date: Sat, 19 Dec 2020 09:23:11 +0900 (JST)
Subject: [ruby-changes:64310] d40d95296d (master): Feature 17314: update docs and NEWS about attr* methods returning array of symbols
https://git.ruby-lang.org/ruby.git/commit/?id=d40d95296d From d40d95296d0947edf513ad5bc7d4bf338b2e3877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Bu=C5=82at?= <radek.bulat@g...> Date: Fri, 18 Dec 2020 17:40:31 +0100 Subject: Feature 17314: update docs and NEWS about attr* methods returning array of symbols diff --git a/NEWS.md b/NEWS.md index 11d33d4..39ddf37 100644 --- a/NEWS.md +++ b/NEWS.md @@ -249,6 +249,10 @@ Outstanding ones only. https://github.com/ruby/ruby/blob/trunk/NEWS.md#L249 p C.ancestors #=> [C, M1, M2, Object, Kernel, BasicObject] ``` + * Module#attr_accessor, Module#attr_reader, Module#attr_writer and Module#attr + methods now return array of defined methods names as symbols. + [[Feature #17314]] + * Mutex * `Mutex` is now acquired per-`Fiber` instead of per-`Thread`. This change @@ -704,3 +708,4 @@ end https://github.com/ruby/ruby/blob/trunk/NEWS.md#L708 [Feature #17351]: https://bugs.ruby-lang.org/issues/17351 [Feature #17371]: https://bugs.ruby-lang.org/issues/17371 [GH-2991]: https://github.com/ruby/ruby/pull/2991 +[Feature #17314]: https://bugs.ruby-lang.org/issues/17314 diff --git a/object.c b/object.c index b50a3b9..b532dd3 100644 --- a/object.c +++ b/object.c @@ -2255,10 +2255,10 @@ id_for_attr(VALUE obj, VALUE name) https://github.com/ruby/ruby/blob/trunk/object.c#L2255 /* * call-seq: - * attr_reader(symbol, ...) -> nil - * attr(symbol, ...) -> nil - * attr_reader(string, ...) -> nil - * attr(string, ...) -> nil + * attr_reader(symbol, ...) -> array + * attr(symbol, ...) -> array + * attr_reader(string, ...) -> array + * attr(string, ...) -> array * * Creates instance variables and corresponding methods that return the * value of each instance variable. Equivalent to calling @@ -2283,9 +2283,9 @@ rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L2283 /** * call-seq: - * attr(name, ...) -> nil - * attr(name, true) -> nil - * attr(name, false) -> nil + * attr(name, ...) -> array + * attr(name, true) -> array + * attr(name, false) -> array * * The first form is equivalent to #attr_reader. * The second form is equivalent to <code>attr_accessor(name)</code> but deprecated. @@ -2314,8 +2314,8 @@ rb_mod_attr(int argc, VALUE *argv, VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L2314 /* * call-seq: - * attr_writer(symbol, ...) -> nil - * attr_writer(string, ...) -> nil + * attr_writer(symbol, ...) -> array + * attr_writer(string, ...) -> array * * Creates an accessor method to allow assignment to the attribute * <i>symbol</i><code>.id2name</code>. @@ -2339,8 +2339,8 @@ rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L2339 /* * call-seq: - * attr_accessor(symbol, ...) -> nil - * attr_accessor(string, ...) -> nil + * attr_accessor(symbol, ...) -> array + * attr_accessor(string, ...) -> array * * Defines a named attribute for this module, where the name is * <i>symbol.</i><code>id2name</code>, creating an instance variable @@ -2350,7 +2350,7 @@ rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L2350 * Returns an array of defined methods names as symbols. * * module Mod - * attr_accessor(:one, :two) + * attr_accessor(:one, :two) #=> [:one, :one=, :two, :two=] * end * Mod.instance_methods.sort #=> [:one, :one=, :two, :two=] */ -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/