From: "David A. Black" Date: 2009-11-17T20:57:43+09:00 Subject: Re: Class inside a Method Body Hi -- On Tue, 17 Nov 2009, Mike Stephens wrote: > Brian > > Thanks for confirming it is a language feature. I was actually using the > method as a kind of procedure - I just wanted this bit of the whole > program to run. In that kind of procedural view of the world it does > make absolute sense for a class to be declared whenever the procedure > is called. > > I think this is part of a difficulty I have with Ruby - it seems to want > to interpret everything in a program, and all the programs called > (required), before it starts executing anything. It's more like execution and interpretation are, in effect the same process -- so, for example: class C puts "hi!" def x puts "x" end puts "bye!" end the code is executed as it's encountered, and you get output before and after the execution of the method definition. (Of course the method body isn't executed until there's an object to which to send the "x" method.) David -- THE COMPLEAT RUBYIST, Ruby training with Black/Brown/McAnally! January 22-23, Tampa, Florica Info and registration at http://www.thecompleatrubyist.com -------------------------------------- My new job: http://tinyurl.com/yfpn9hz