From: thomas coopman Date: 2006-06-20T01:35:33+09:00 Subject: Re: best way to deal with command line options On Tue, 20 Jun 2006 00:45:00 +0900 Matthew Smillie wrote: > > Another little question, what's the best way to do when writing a > > program in ruby, > > keep the core and the main in different files, place them in the > > same file,.. or doesn't it matter? > > To be honest, I'm not 100% sure what you mean by 'main'. I'm > guessing it's something like this: > > Class A > ... > end > Class B > ... > end > > # 'main' starts here. > a = A.new > ... > > > In one sense it doesn't matter. But including things like that in > the same file can lead to problems if you ever want to use your > classes in a different file - your 'main' will get executed when you > 'require' the original file. It's likely best in the long run to > separate specific programs using your classes from the classes > themselves. If you feel like cheating, though, you can always do this: > > if $0 == __FILE__ > # main goes in here > end > > matthew smillie > Thanks for your answers! Thomas Coopman