From: Alex N Date: 2012-02-14T20:23:14+09:00 Subject: [ruby-core:42612] [ruby-trunk - Bug #6020] Unexpected is_a/kind_of behaviour Issue #6020 has been updated by Alex N. =begin Yes, i know how instance is_a? works. The problem is that the module owns the same functionality as well. For example: module A; end A.class #=> Module A.is_a?(A) #=> false A.is_a?(A.class) #=> true From implementation perspective it's totally ok: Module is not A. But (({A.ancestors})) is (({[A]})), meanwhile (({Module.ancestors})) it the whole set of the core objects. At the same time module A is an BasicObject. I'm not saying that it's completely wrong, but it feels confusing. On the other had it's really really edge case. =end ---------------------------------------- Bug #6020: Unexpected is_a/kind_of behaviour https://bugs.ruby-lang.org/issues/6020 Author: Alex N Status: Feedback Priority: Low Assignee: Category: core Target version: ruby -v: ruby 2.0.0dev (2012-02-14 trunk 34598) [x86_64-darwin11.3.0] =begin I've noticed some inconsistent is_a?/kind_of? methods behavior in a very special cases self.class #=> Object BasicObject.is_a?(BasicObject) #=> true Module.is_a?(Module) #=> true Class.is_a?(Class) #=> true Object.is_a?(Object) #=> true BasicObject.is_a?(Module) #=> true Integer.is_a?(Integer) #=> false class A; end A.is_a?(A) #=> false module B; end B.is_a?(B) #=> false class C < Object; end C.is_a?(C) #=> false C.is_a?(Object) #=> true C.is_a?(BasicObject) #=> true C.is_a?(Module) #=> true C.is_a?(Class) #=> true c = C.new c.is_a?(Module) #=> false c.is_a?(Class) #=> false It looks like it's because Class, Module, Object and BasicObject have class Class, superclass is set properly. Anyway all is logical but not expected. =end -- http://bugs.ruby-lang.org/