2009/2/6 Julian Leviston <julian / coretech.net.au>:
> What do you mean by faster? For who?

------------------------
class MyClass

	class << self
		puts "Starting MyClass..."
		@my_var = 1
	end

	class << self
		def hello
			puts "hello I'm MyClass"
		end
	end

end


class MyClass2

	def initialize
		puts "Initializing instance of MyClass2..."
		@my_var = 1
	end
	
	def hello
		puts "hello I'm instance of MyClass2"
	end

end

MyClass.hello
MyClass.hello

MyClass2.new.hello
MyClass2.new.hello
------------------------


output:

--------------------
Starting MyClass...
hello I'm MyClass
hello I'm MyClass
Initializing instance of MyClass2...
hello I'm instance of MyClass2
Initializing instance of MyClass2...
hello I'm instance of MyClass2
--------------------



As you see, the MyClass code:
  		puts "Starting MyClass..."
		@my_var = 1
is executed *just* at the start of the program, while the code:
		puts "Initializing instance of MyClass2..."
		@my_var = 1
is executed for each MyClass2 initialization (logic of course).


Regards.

-- 
Iaki Baz Castillo
<ibc / aliax.net>