From: "Jesús Gabriel y Galán" Date: 2012-08-16T22:11:53+09:00 Subject: Re: extending class, namespace question On Thu, Aug 16, 2012 at 2:16 PM, Ronnie Aa wrote: > Hi everybody, > > > I have this: > > > class Fixnum > def times_print(str) > times { puts str } > end > end > > > > > module Bb > def self.test > 10.times_print('foo') > end > test > end > > It works.. > > But if some other .rb uses the same name for its Fixnum class extension, > including different methods, there will be collision ?? > > > > So I tried to wrap my class extension in a module like this: > > > module Aa > class Fixnum > def times_print(str) > times { puts str } > end > end > end > > > > module Bb > include Aa > def self.test > > 10.times_print('foo') > end > test > end > > The class-extention in module Bb does not work, how do I solve this>?? When you say module Aa class Fixnum This is not the same Fixnum as the top-level Fixnum. This is Aa::Fixnum, of which 10 is not an instance. You can refer to a top-level constant prefixing it with "::". So: module Aa class ::Fixnum ... Jesus.