From: "Jesús Gabriel y Galán" Date: 2009-04-23T23:22:27+09:00 Subject: Re: Class variable confusion On Thu, Apr 23, 2009 at 4:01 PM, Keith Salisbury wrote: > Or more simply, i would like this to update the variable @greeting, when > i call Keith.learn_french: > > module Keith >  def self.greeting >    @greeting ||= "hello" >  end >  def self.greeting=(value) >    puts "updating knowledge" >    @greeting = value >  end >  def self.speak >    puts greeting >  end >  def self.learn_french >    learn_language(greeting, "bonjour") Here, you are calling the greeting method (which returns "hello") >  end >  def self.learn_language(prop, value) >    prop = value Here you are reassigning a local variable, which goes out of scope when the method ends. Try this: jesus@jesus-laptop:~/temp/ruby$ ruby class_variables.rb hello bonjour jesus@jesus-laptop:~/temp/ruby$ cat class_variables.rb module Keith def self.greeting @greeting ||= "hello" end def self.greeting=(value) puts "updating knowledge" @greeting = value end def self.speak puts greeting end def self.learn_french learn_language(:@greeting, "bonjour") end def self.learn_language(prop, value) instance_variable_set(prop, value) end end Keith.speak Keith.learn_french Keith.speak or if you want to call the self.greeting= method, try this variation: def self.learn_french learn_language(:greeting, "bonjour") end def self.learn_language(prop, value) send("#{prop}=", value) end Hope this helps, Jesus.