From: Dejan Dimic Date: 2007-12-31T07:09:58+09:00 Subject: Re: newbie question - how to use multiple source files On Dec 30, 6:36 pm, Ben Hoffmann wrote: > I'm coming from Java, and am trying to understand how to break upo code > into more than one file. So in this example, I have one class in the > first file, another in the second file, and I want to create an object > from the first class, but from the second file. Environment - Aptana on > XP machine. See below: > > 1) First file named first_class_file.rb: > > class FirstClassFile > > public > > def initialize > super > puts "Hello from First Class" > end > end > > my1stObject = FirstClassFile.new > > 2) Second file named second_class_file.rb: > > class SecondClassFile > > def initialize > super > puts "Hello from Second Class" > end > end > > my2ndObject = SecondClassFile.new > > my3rdObject = FirstClassFile.new > > 3) Console result of running second file: > > Hello from Second Class > second_class_file.rb:11: uninitialized constant FirstClassFile (NameError) > > Question - What obvious thing am I doing wrong? > Thanks! > - Ben Coming from Java I presume that you are familiar with import directive. Ruby has "require" for the same job as stated before.