From: Julian Leviston Date: 2011-02-27T18:37:55+09:00 Subject: Re: Newbie question Actually it depends what you want to do. There is no "always do this" type of rule... We encourage understanding and experimentation and best practices to the limits of our understanding. If your class was simply to output some values who's to say you can't instantiate variables inside the class definition... His code is just fine... Personally I'd never write code like that because it doesn't support reuse very well and every time the class is defined and run, it prints out some stuff which isn't very helpful in all contexts. Julian On 27/02/2011, at 1:32 PM, botp wrote: > On Sun, Feb 27, 2011 at 9:29 AM, Marc Chanliau wrote: >> In Ruby it seems you can instantiate a class inside the class itself or >> outside. > > that's ok, if you want to be my-class-centric rather than ruby's main > centric. downside is, you cannot create instances of your > class-centric class outside without invoking your class-centric > instances inside that class-centric class. in short, you're losing > some ease-of-use features. but hey, maybe that is what you want and > have a use for it, and ruby happily does not prevent you :) > >> What is the accepted convention? > > this is ruby. either there are no rules nor convention, or there are many :) > > best regards -botp >