From: Phrogz Date: 2007-01-11T15:15:09+09:00 Subject: Re: statement outside of any method in a class Paul Smith wrote: > Thanks for the explanation David. > > However, it is still not clear to me when these statements are invoked. > > In your example, what triggers the execution of the 2 statements? [snip] > When the class is loaded, when an instance of that class is created? > Is this similar to a static initialization block in Java? Instead of asking and waiting for an answer, perhaps just try running the following code: puts "Line 1" class Foo puts "Inside Foo on line 4" def bar puts "Running #bar method (line 6)" end puts "All done with #{self} (line 8)" end puts "Line 11" f = Foo.new f.bar puts "Last line (16)"