Recently, I’ve read
I’m trying to draw a picture of hierarchy for the following:
@@k = 20
class Bar < Foo
@j = 10
def initialize @i = 0 end
b = Bar.new
I understand how to draw hierarchy if it were not for class variables:
Class ^ | +-------+ | | (Foo) <-(Bar) ^ ^ - Bar's class methods | | Foo <- Bar ^ - j and Bar's instance methods | b - i
In this picture parenthesis represents meta class. Upward arrows
represents ‘class’, while leftward arrows represents ‘inherits’.
But, I have no idead where the class variable k should belong to. k is
shared by Foo and Bar which menas that if k is modified at Foo, then
the value of k at Bar will be modified also. That being the case, does
k must be drawn under (Foo)? or Class?
- Minkoo S.