From: Robert Klemme Date: 2010-06-12T18:00:04+09:00 Subject: Re: How can I call foo in Bar.foo ? On 06/12/2010 07:33 AM, Ntys Dd wrote: > it's like this > ........................ > module Bar > def foo > puts 'hello' > end > def bye > puts 'bye' > end > end > > def Bar.foo > #Do something > #I want to call foo now > #And call bye > #... > end > ........................ > > is there anything i can to to solve the problem It does not really make sense since the first #foo you define is an instance method while the latter is a class method. When you have a class you do not have an instance available so on what instance would you intend to invoke #foo on? It can only work the other way round: you have the instance method invoking the class (module) method. module Bar def self.foo puts "module method" end def foo puts "instance method" Bar.foo end end irb(main):011:0> o = Object.new.extend Bar => # irb(main):012:0> o.foo instance method module method => nil Of course you can also do module Bar def uber_foo foo bye end end Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/