I have two Ruby files. I am able to access the class of one of the files
but not the other. Here are my two files:
bankaccount.rb:
# http://www.techotopia.com/index.php/Ruby_Object_Oriented_Programming
class BankAccount
def initialize ()
end
def test_method
puts "The class is working"
end
end
complex.rb:
class ComplexNumber
def initialize()
end
def a
@a = 0
end
def b
@b = 0
end
end
I can create a BankAccount object just fine in the IRB, but when I try
to create a ComplexNumber object I get an error saying "unitialized
constant" even though I entered 'load "complex.rb"' and 'load
"bankaccount.rb"'.
irb(main):008:0> a = BankAccount.new()
=> #<BankAccount:0x2b0fc50>
irb(main):009:0> b = ComplexNumber.new()
NameError: uninitialized constant ComplexNumber
from (irb):9
from C:/Ruby193/bin/irb:12:in `<main>'
···
--
Posted via http://www.ruby-forum.com/.