thank you very much!Your answer make me understand more about object in 
ruby.I am very glad.But still ,i have another question.Please read an 
example following:
class Test
def initialize
e="e"
end
def Test.say_hello
puts "Hello from #{self.name}"
puts "hello from #{self.class}"
end
say_hello
end

Your means is 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.Can you explain it for me?What is more,if it is a 
instance method ,i can not get any result.why?
 thank you !



FireAphis wrote:
> On Jul 26, 6:43 am, Guo Yangguang <gy... / 163.com> wrote:
>> --
>> Posted viahttp://www.ruby-forum.com/.
> 
> I hope I understand your question correctly.
> 
> Ruby is in its essence an interpreter. When you type in your command
> prompt
> 
>>ruby my_script.rb
> 
> the interpreter (that by itself is just another application) reads
> your file line by line and executes every line. Think of every line in
> Ruby as a command to the interpreter and that the interpreter executes
> every single line. That means you can use your classes anywhere you
> like as long as they were defined before. For example, this is
> absolutely correct in Ruby:
> 
> a = "I assign even before any declaration"
> puts "Moreover I can output its value #{a}"
> 
> (1..10).each {|x| puts "#{x} I can do anything I wish"}
> 
> class C1
>    puts "When interpreter will read this he will print. Not very
> useful but possible"
>    def a()
>    end
> end
> 
> c = C1.new # now we can use our class
> puts "We can do something in between..."
> 
> class C2
>    puts "We can define another class"
>    def b
>    end
> end
> 
> puts "And so on..."
> 
> 
> As you can see it's quite different from Java. If you want to feel
> more comfortable think of your Ruby code written entirely inside one
> big 'main' Java function. Just remember - every line is executed!
> 
> FireAphis

-- 
Posted via http://www.ruby-forum.com/.