From: Iain Barnett Date: 2010-09-29T01:42:19+09:00 Subject: Re: error message, undefined method in Set On 28 Sep 2010, at 07:11, Brian Candler wrote: > Iain Barnett wrote: >> but this throws errors: >> >> require 'choice' >> require 'set' > > Then at the top of choice.rb I'd put require 'set'. That's what I was originally doing, but a lot of the advice I've read on structuring projects is to remove the requires from individual classes/files and put them in a central file with the name of the app under lib. > >> I'm very surprised that the order of requires (at the top of a file) can >> affect anything in this way. Is this the way it's supposed be? If not, >> what could be the cause? > > It can be. Imagine this: > > --- set.rb --- > class Set < Hash > ... > end > > --- choice.rb --- > class Set > ... add some more methods to the class > end > > If you require choice.rb first, you would get an exception when > requiring set.rb Ok, thanks. It's good to know gotchas! Regards, Iain