On Sun, 13 May 2001, Sean Russell wrote: > class Date > class << self > def once(*ids) > # ... > end > end > # ... > end This adds a method to the Date class object, not to instances of Date. You call this method using Date.once() instead of a_date = Date.new; a_date.once(). No different than saying def Date.once(*ids) but arguably more convienient if you have a bunch of class methods to add. > Question 2 > > Why doesn't the following do what I'd expect it to, and how does > one solve this type of problem? > > module Child > @level = 0 > attr :level, true > end At the time you are calling @level=, self is the module not an instance. Try changing this to: module Child attr :level, true def initialize super @level = 0 end end Applied consistantly, initialize in all included modules will be called. BUT, this forces the argument count to be zero, so if you have arguments to new someone is going to have to call super() to get rid of the args. You could use def initialize( *ignored_args ) but that just moves the problem since Object's initialize takes no args. I don't know of a good solution. > Question 3 > > class A ; def initialize ; puts "In A" ; end ; end > class B < A ; def initialize ; puts "In B" ; end ; end > b = B.new > > generates: > > In B The superclass must be called explicitly: class A ; def initialize ; puts "In A" ; end ; end class B < A ; def initialize ; super ; puts "In B" ; end ; end b = B.new - Eric B. -- "What not why"