Jim Freeze <jim / freeze.org> writes:

> What is the difference (if any) between the following
> two method definitions:
> 
> method A
>   def a
>     1
>   end
> end
> 
> method A
>   def A.a
>     1
>   end
> end

Assuming you meant 'module A', the first defines an instance method,
the second a module method. The instance method cannot be called until
the module is mixed in to a class using 'include'. The module method
can be called by giving the module name as a receiver:

  module A
    def a
      puts "in a"
    end
  end

  class X
    include A
  end

  x = X.new
  x.a        #=> in a

  module B
    def B.a
      puts "in B.a"
    end
  end

  B.a        #=> in B.a



Dave