From: "sawa (Tsuyoshi Sawada)" Date: 2022-01-31T05:02:47+00:00 Subject: [ruby-core:107386] [Ruby master Bug#11064] #singleton_methods for objects with special singleton_class returns an empty array Issue #11064 has been updated by sawa (Tsuyoshi Sawada). matz (Yukihiro Matsumoto) wrote in #note-1: > `nil` does not have its singleton class, but `NilClass` plays the role of the singleton class I would appreciate it if @matz could kindly explain what the difference is between "being a singleton class" and "playing the role of a singleton class". At the moment, I cannot understand at all how they are different. I am actually puzzled by a related comment by matz: https://bugs.ruby-lang.org/issues/12084#note-6. Why can we not simply say "`NilClass` is the singleton class of `nil`"? ---------------------------------------- Bug #11064: #singleton_methods for objects with special singleton_class returns an empty array https://bugs.ruby-lang.org/issues/11064#change-96288 * Author: rbjl (Jan Lelis) * Status: Open * Priority: Normal * ruby -v: ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- ~~~ def nil.bla 42 end # works nil.bla #=> 42 nil.singleton_method(:bla) #=> # NilClass.instance_methods.include? :bla #=> true # does not work nil.singleton_methods #=> [] ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: