diff options
author | Ufuk Kayserilioglu <ufuk@paralaus.com> | 2022-09-27 01:19:22 +0300 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2022-10-20 17:30:17 +0200 |
commit | 0378e2f4a8319440dd65c82b16f189161472d237 (patch) | |
tree | 6c2c6dd91c624fd4ae6ad4be5dd3a6d04528df37 /NEWS.md | |
parent | 192bc725290ca4b271bff2bae6123d84c25f7173 (diff) |
Add Class#attached_object
Implements [Feature #12084]
Returns the object for which the receiver is the singleton class, or
raises TypeError if the receiver is not a singleton class.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6450
Diffstat (limited to 'NEWS.md')
-rw-r--r-- | NEWS.md | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -115,6 +115,21 @@ Note: We're only listing outstanding class updates. STDIN.read # => Blocking operation timed out! (IO::TimeoutError) ``` +* Class + * `Class#attached_object`, which returns the object for which + the receiver is the singleton class. Raises `TypeError` if the + receiver is not a singleton class. + [[Feature #12084]] + + ```ruby + class Foo; end + + Foo.singleton_class.attached_object #=> Foo + Foo.new.singleton_class.attached_object #=> #<Foo:0x000000010491a370> + Foo.attached_object #=> TypeError: `Foo' is not a singleton class + nil.singleton_class.attached_object #=> TypeError: `NilClass' is not a singleton class + ``` + * Data * New core class to represent simple immutable value object. The class is similar to `Struct` and partially shares an implementation, but has more @@ -323,6 +338,7 @@ The following deprecated APIs are removed. ## Miscellaneous changes [Feature #12005]: https://bugs.ruby-lang.org/issues/12005 +[Feature #12084]: https://bugs.ruby-lang.org/issues/12084 [Feature #12655]: https://bugs.ruby-lang.org/issues/12655 [Feature #12737]: https://bugs.ruby-lang.org/issues/12737 [Feature #13110]: https://bugs.ruby-lang.org/issues/13110 |