Beginner question on classes on different files



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?
Thansk, Edgard

--
Posted via http://www.ruby-forum.com/.


.



Relevant Pages