Modules as namespace

i am writing plugins for sketchup and use a module to encapsulate and
protect my variable and methods from name clashes.

Is there any difference between the following?

module A
  def A.say_hi # or self.say
    puts "hi"
  end
end

module B; end
def B.say_hi
  puts "hi"
end

thanks.

Hi --

i am writing plugins for sketchup and use a module to encapsulate and
protect my variable and methods from name clashes.

Is there any difference between the following?

module A
def A.say_hi # or self.say
   puts "hi"
end
end

module B; end
def B.say_hi
puts "hi"
end

The only difference I'm aware of has to do with constant resolution:

   H = "Hi from top level"

   module A
     H = "Hi from A"
     def A.say_hi
       puts H
     end
   end

   module B
     H = "Hi from B"
   end

   def B.say_hi
     puts H
   end

   A.say_hi # Hi from A
   B.say_hi # Hi from top level

David

···

On Tue, 8 Sep 2009, Jim wrote:

--
David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
Ruby/Rails training, mentoring, consulting, code-review
Latest book: The Well-Grounded Rubyist (http://www.manning.com/black2\)

September Ruby training in NJ has been POSTPONED. Details to follow.

Thank you, David. I wasn't even thinking about constants, but that's
good to know.