From: matz@... Date: 2017-03-02T09:27:08+00:00 Subject: [ruby-core:79861] [Ruby trunk Bug#13257][Feedback] Symbol#respond_to?(:singleton_class) should be false (but true) Issue #13257 has been updated by Yukihiro Matsumoto. Status changed from Open to Feedback Fundamentally, `#respond_to?` is a method to check method existence. The class Symbol does have `#singleton_class` so that it's natural for it to return `true`, even though `#singleton_class` always fails. It seems you want to check the availability of functionality. That means you want to change the meaning of the method. I do not reject the proposal immediately, but at least it's controversial. Persuade us if you really want to change it. Matz. ---------------------------------------- Bug #13257: Symbol#respond_to?(:singleton_class) should be false (but true) https://bugs.ruby-lang.org/issues/13257#change-63292 * Author: Satoshi TAGOMORI * Status: Feedback * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin15] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- Objects of some classes doesn't have singleton classes (e.g., Symbol, Integer, Float...). Symbol#singleton_class raises TypeError. But Symbol#respond_to?(:singleton_class) returns true, and we cannot know when `#singleton_class` returns a valid class or raise errors in any way (except for calling it). Symbol#respond_to?(:singleton_class) should return false for such cases. (Integer, Float and other classes without singleton_class too.) -- https://bugs.ruby-lang.org/ Unsubscribe: