B
Ben Hoffmann
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
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