This is below is an example of superclass/subclass construct :
C:\>irb --simple-prompt
>> class Parent
>> @@x = 10
>> end
=> 10
>> class Child < Parent
>> @@x = 12
>> end
=> 12
>> class Parent
>> puts "@@X = #{@@x}"
>> end
@@X = 12
=> nil
And the above is also understood.But I wanted to check if possible or not when two class are defined seprately as an standalone class
anyway to define the super/sub relation between them?
I tried the below but it doesn't work. May be not the way I tried:
C:\>irb --simple-prompt
>> class Parent
>> @@X = 10
>> end
=> 10
>> class Child
>> @@x = 15
>> end
=> 15
>> class Child < Parent
>> def show
>> p "hi"
>> end
>> end
TypeError: superclass mismatch for class Child
from (irb):7
from C:/Ruby193/bin/irb:12:in `<main>'
>>