From: Stefan Mahlitz Date: 2006-02-01T01:34:22+09:00 Subject: Re: Beginner question on classes on different files Edgard Riba wrote: > Hi, > I'm beginning to work with ruby and I have a conceptual problem. Let's > say I have two files: > > hello2.rb: > class Hello2 > attr_reader :msg > def initialize > @msg = "Hello, World2" > end > end > > and hello.rb > > require 'hello2.rb' > class Hello > attr_reader :msg > def initialize > @msg = "Hello, World" > end > end > h = Hello.new() > h2 = Hello2.new() > puts h2.msg > puts h.msg > print "Press RETURN" > $stdin.gets > > This is obviously a conceptual excercise. I want to use class > "Hello2" in my hello.rb code. However this doesn't compile. > > What is wrong with this code? How is something like this done in Ruby? Works for me under linux and windows. Prints > Hello, World2 > Hello, World > Press RETURN What exactly does not work?