From: Joel VanderWerf Date: 2001-12-16T04:22:11+09:00 Subject: [ruby-talk:28639] Re: assigning to class variable works in string, not in block ts wrote: > > >>>>> "J" == Joel VanderWerf writes: > > Write it like this > > J> module M > J> def self.append_features base_class > J> base_class.class_eval {@@base_class = self} # fails > J> # base_class.class_eval "@@base_class = self" # ok > J> end > J> end > > module M > class << self > def append_features base_class > base_class.class_eval {@@base_class = self} > end > end > end Thanks, Guy, that works. Was the problem that @@base_class was not getting bound to the class variable of BaseClass, because it was referenced in a block whose scope was module M? But then why did the error message refer to BaseClass, and not M: "uninitialized class variable @@base_class in BaseClass (NameError)"? -- Joel VanderWerf California PATH, UC Berkeley mailto:vjoel@path.berkeley.edu Ph. (510) 231-9446 http://www.path.berkeley.edu FAX (510) 231-9512