[ruby-talk:02487] Re: Module functions

From: matz@... (Yukihiro Matsumoto)
Date: 2000-04-15 15:10:02 UTC
List: ruby-talk #2487
Hi,

In message "[ruby-talk:02486] Module functions"
    on 00/04/15, Dave Thomas <Dave@thomases.com> writes:

|Is there any difference between
|
|  module Dave
|    def Dave.dave
|      # ..
|    end
|  end
|
|and
|
|  module Dave
|    def dave
|      # ..
|    end
|    module_function :dave
|  end
|
|The Dave.dave form seems to be more intuitive, and more in line with
|the class method approach.

There's difference.

  module Dave
    def dave
      # ..
    end
    module_function :dave
  end

works like
  
  module Dave
    def dave
      # ..
    end
    private :dave       # method visibitili change
    def Dave.dave       # copies method body for class method
      # ..
    end
  end

See?
							matz.

In This Thread