This gist has a bigger example of what I'm trying to do, but just
understanding how to make the following short example work, and/or why
it doesn't, will probably get me through the bigger problem.
testit.rb:
require 'pp'
class A
@@a = [7]
def self.get_a
@@a
end
def self.put_a
pp @@a
end
end
class B < A
@@a = A.get_a.dup
@@a = [8]
def self.put_a
pp @@a
end
end
A.put_a
B.put_a
A.put_a
[wwalker@dogwood inherit_settings] $ ruby testit.rb
[8]
[8]
[8]
I would expect:
[7]
[8]
[7]
I don't see my error. I think that maybe dup() doesn't work on a class
variable, or that maybe class variables are not really class variables,
but are rather hierarchy variables that can only exist in one place in
an class and it ancestry?
···
--
Wayne Walker
wwalker@solid-constructs.com
(512) 633-8076
Senior Consultant
Solid Constructs, LLC
A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> > A: Top-posting.
> > > Q: What is the most annoying thing in e-mail?