From: Dave Thomas Date: 2002-11-21T14:42:35+09:00 Subject: Re: [FAQ] Interpreted vs compiled [FAQ] defining methods anywhere Mark Wilson writes: > Please explain how methods in an explicit class are different than > methods in the Object class. They aren't - it's just a question of when they are called: bert def bert ... end Here, the call to bert is *executed* before the definition of bert: it fails. class Dave def initialize bert end def bert ... end end Here the call to 'bert' in initialize is parsed, but not executed. The method 'bert' is then defined. Later when you execute Dave.new, the call to bert succeeds, because the method is defined at that point. The fact that method definitions are active code means you can do things such as if $DEBUG def fred puts "lots of logging" do stuff... puts "more logging" end else def fred do stuff... end end Cheers Dave