From: nobuyoshi nakada Date: 2005-05-26T15:23:01+09:00 Subject: Re: if __FILE_ == $0 executed twice Hi, At Wed, 25 May 2005 21:55:39 +0900, Han Holl wrote in [ruby-talk:143610]: > > Why not move the `if' block to another file (with no suffix), like > > irb for instance? > > > Under the if are mostly tests. The files are meant as libraries. It's > nice to have the tests nearby, and not in a seperate file. Another way is put the tests after __END__ line. See InlineTest#loadtest__END__part in test/inlinetest.rb. > Is there a reason why $0 is not required ? It seems a logical thing to do. > Would it break things ? Till 1.8, $: includes `require'd names relative to one of $LOAD_PATH, $0 is absolute path or relative from cwd in other hand. So comparing $0 with $: had no meanings, however it might be in 1.9. -- Nobu Nakada