Getting a method object directly from a module

D

Daniel Berger

Hi all,

Is it possible to get a method object from a Module directly? This
doesn't work:

module Foo
def my_method
end
end

method = Foo.method:)my_method)
=> NameError: undefined method `my_method' for class `Module'

Is there a way to do what I mean?

Regards,

Dan
 
K

Kent Sibilev

irb(main):001:0> module M
irb(main):002:1> def m
irb(main):003:2> end
irb(main):004:1> end
=3D> nil
irb(main):005:0> M.instance_method:)m)
=3D> #<UnboundMethod: M#m>

Kent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,237
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top