Created
January 30, 2013 17:24
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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