From: Brian Candler Date: 2011-01-07T00:48:24+09:00 Subject: Re: Class Initialization? Kedar Mhaswade wrote in post #972556: > It was not clear if the "class body" will be executed at most once. > That's now clear. And indeed, the execution of the code is what defines the class. The class and methods are defined *at runtime*. Foo.bar rescue nil # uninitialized constant Foo class Foo def self.bar puts "hello!" end end Foo.bar # this works Amongst other things, this means you can conditionally define classes and methods. However the code will be executed multiple times if you force it to be - for example using 'load' instead of 'require'. This can also happen if you require the same file using variations of the name, e.g. require 'foo' require './foo' require '/path/to/foo' -- Posted via http://www.ruby-forum.com/.