From: Thufir Date: 2007-12-31T07:22:19+09:00 Subject: Re: newbie question - how to use multiple source files On Mon, 31 Dec 2007 02:36:28 +0900, Ben Hoffmann wrote: > 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, Hi :) I'm coming from java, too. Heads up: one of the big but silly differences is to not capitalize file names, like Foo.rb, instead call it foo.rb. How about something like the following (note the output of "ruby driver.rb"): thufir@arrakis ~/Desktop/foobar $ ll total 12 -rw-r--r-- 1 thufir users 53 Dec 30 14:17 bar.rb -rw-r--r-- 1 thufir users 86 Dec 30 14:18 driver.rb -rw-r--r-- 1 thufir users 53 Dec 30 14:17 foo.rb thufir@arrakis ~/Desktop/foobar $ thufir@arrakis ~/Desktop/foobar $ ruby driver.rb hello from a foo hello from a bar thufir@arrakis ~/Desktop/foobar $ cat driver.rb require 'foo.rb' require 'bar.rb' foo = Foo.new foo.hello bar = Bar.new bar.hello thufir@arrakis ~/Desktop/foobar $ thufir@arrakis ~/Desktop/foobar $ cat foo.rb class Foo def hello puts "hello from a foo" end end thufir@arrakis ~/Desktop/foobar $ thufir@arrakis ~/Desktop/foobar $ cat bar.rb class Bar def hello puts "hello from a bar" end end thufir@arrakis ~/Desktop/foobar $ The driver, driver.rb, does all the work. You may be interested in the code at: http://code.google.com/p/dwemthys/source HTH, Thufir