Skip to content

Instantly share code, notes, and snippets.

@floehopper
Last active January 4, 2016 14:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floehopper/8637991 to your computer and use it in GitHub Desktop.
Save floehopper/8637991 to your computer and use it in GitHub Desktop.
Differences between ancestors of singleton class between Ruby v2.0 and v2.1
# ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]
class X; end
X.ancestors # => [X, Object, Kernel, BasicObject]
X.singleton_class # => #<Class:X>
X.singleton_class.ancestors # => [Class, Module, Object, Kernel, BasicObject]
# ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]
class X; end
X.ancestors # => [X, Object, Kernel, BasicObject]
X.singleton_class # => #<Class:X>
X.singleton_class.ancestors # => [#<Class:X>, #<Class:Object>, #<Class:BasicObject>, Class, Module, Object, Kernel, BasicObject]
# The following are extra ancestors in Ruby v2.1
# [#<Class:X>, #<Class:Object>, #<Class:BasicObject>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment