J
Jon A. Lambert
I want to add instance methods to a class at runtine.
$ cat testcmds.rb
module Bar
def hello
puts "hello called"
end
end
class Foo
end
Foo.include(Bar)
Foo.new.hello
$ ruby testcmds.rb
testcmds.rb:10: private method `include' called for Foo:Class
(NoMethodError)
How can I do this?
$ cat testcmds.rb
module Bar
def hello
puts "hello called"
end
end
class Foo
end
Foo.include(Bar)
Foo.new.hello
$ ruby testcmds.rb
testcmds.rb:10: private method `include' called for Foo:Class
(NoMethodError)
How can I do this?