Skip to content

Instantly share code, notes, and snippets.

@pmarreck
Created January 30, 2013 17:24
Show Gist options
  • Save pmarreck/4674873 to your computer and use it in GitHub Desktop.
Save pmarreck/4674873 to your computer and use it in GitHub Desktop.
futzing around with changing what the inheritance of a class is. (objects made with the old class will still use the old class' inheritance, though)
bash>> irb
class A;>> class A; end
=> nil
>> class B; end
=> nil
>> the_class = A
=> A
>> class C < the_class
>> end
=> nil
>> C.ancestors
=> [C, A, Object, Kernel, BasicObject]
>> the_class = B
=> B
>> class C < the_class
>> end
TypeError: superclass mismatch for class C
from (irb):8
from /Users/pmarreck/.rvm/rubies/ruby-1.9.3-p327/bin/irb:16:in `<main>'
>> C = Class.new(the_class)
(irb):10: warning: already initialized constant C
=> C
>> C.ancestors
=> [C, B, Object, Kernel, BasicObject]
>> # I just changed C's ancestor...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment