From: Guo Yangguang Date: 2007-07-29T17:20:07+09:00 Subject: Re: how can i use a ruby class in object way Sorry ,i am not show it very clear.Please read this example again: class Test def Test.say_hello puts "Hello from #{self.name}" puts "hello from #{self.class}" end say_hello #i don't understand here end Normally,we can use a class anyplaces after defining it ,but in this example,i use a classmehod immediately after defining it "in class context".This is valid.I means calling a classmethod(not an intance method) in a class defintion--not after defining that class--is valid .Can you explain it for me? thank you ! Robert Dober wrote: > On 7/29/07, Guo Yangguang wrote: >> end >> say_hello >> end >> > It is not completely clear what you want to achieve but some remarks > might be helpful > > class Test > def initialize > e="e" # this code is not realy useful, e is a scope local > variable that will be thrown away, you probably want to do this: > @e = "e" # this is an instance variable > end > > attr_accessor :e # for some tests below > > def Test.say_hello > ... > end > say_hello > end > > Test.say_hello > aTest = Test.new > puts aTest.e > aTest.e = 42 > puts aTest.e -- Posted via http://www.ruby-forum.com/.