D
DaZoner
Imagine you want to redefine a class at runtime. One way to do it is to load
a different class definition at runtime.
So make two class definitions in separate files and a test script:
bug1.rb --------------------------------------------------------------------
----------
class Bug
def method1
end
end
bug2.rb --------------------------------------------------------------------
----------
class Bug
def method2
end
end
bugtest.rb -----------------------------------------------------------------
------------
load "bug1.rb"
b = Bug.new
list = b.methods
list.each { |methodName| print " ",methodName }
print "\n"
load "bug2.rb"
b = Bug.new
list = b.methods
list.each { |methodName| print " ",methodName }
print "\n"
----------------------------------------------------------------------------
a different class definition at runtime.
So make two class definitions in separate files and a test script:
bug1.rb --------------------------------------------------------------------
----------
class Bug
def method1
end
end
bug2.rb --------------------------------------------------------------------
----------
class Bug
def method2
end
end
bugtest.rb -----------------------------------------------------------------
------------
load "bug1.rb"
b = Bug.new
list = b.methods
list.each { |methodName| print " ",methodName }
print "\n"
load "bug2.rb"
b = Bug.new
list = b.methods
list.each { |methodName| print " ",methodName }
print "\n"
----------------------------------------------------------------------------