Wes Gamble wrote: > All, > > Is there a notion of a class level "static" code block in Ruby that > would get executed whenever the class is loaded? Basically the > equivalent of Java's "static {...}" construct? > > I don't necessarily want to put this in an initialize method because > it's just loading up static data from configuration files. > > Or do I have to put the code into an initialize method in my class and > then guard it so that it's only executed once? > > Thanks, > Wes > > Code placed within the class definition, but not in methods: irb(main):001:0> class A irb(main):002:1> puts "Hello!" irb(main):003:1> end Hello! => nil Note how Hello! is output as soon as the class is parsed. I think this is what you want...? -Justin