From: Brian Candler Date: 2009-06-04T19:27:52+09:00 Subject: Re: Ruby Execution Mike Stephens wrote: > If you have a script with a lot of classes, does the interpreter read > through and 'execute' each class even though they haven't yet been > called? Yes. Everything is done at runtime. * require 'foo' just loads and executes the code in foo.rb. * Code of the form "class X; def m; ..." has the runtime effect of defining methods in classes. * It's quite common to have code which sets up variables and/or constants too. For example: class X @count = 0 def self.create(*args) @count += 1 new(*args) end def self.count @count end end a = X.create b = X.create puts X.count -- Posted via http://www.ruby-forum.com/.