From: Robert Klemme Date: 2009-11-18T01:38:36+09:00 Subject: Re: Class inside a Method Body 2009/11/17 Mike Stephens : > 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. Can you describe under which circumstances you believe this makes sense? After all since the class definition would not change you would get the same class definition over and over again. To me that does not sound useful. If you want to make sure the class is only created when the method is executed, you could put it in a separate file which you require in that method. Alternatively you can use autoload. > 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. If you have a difficulty here I can see two possible explanations: 1. there is an issue with Ruby's object model, 2. you are not using the language properly. While I don't want to exclude option 1, I tend to believe option 2 is more likely. :-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/