From: "Eduardo Mucelli R. Oliveira" Date: 2010-05-05T04:11:26+09:00 Subject: Re: Scope On 4 maio, 13:49, Rick DeNatale wrote: > On Tue, May 4, 2010 at 9:55 AM, Eduardo Mucelli R. Oliveira > > wrote: > > I have a script with those two following classes: > > > class String > >   def to_b > >      ["true"].include?(self.downcase) > >   end > > end > > This opens up the system class String (or ::String if you prefer to > explicitly specify the outer scope) and adds an instance method > available to any instance of ::String > > > > > > > class HereIWantUseToB > >   "string".to_b > > end > > > Ok,  that works fine, the to_b method can be "seen" by > > HereIWantToUseToB class. But I wanted to those two classes inside > > another class, or module, like this: > > > class Everything > >   # The two classes described above are here > > end > > > module Everything > >   # The two classes described above are here > > end > > Either > > class Everything >   class String >      #... >   end > end > > or > > module Everything >   class String >      #... >   end > end > > creates a new class Everything::String, which is unrelated to ::String > > > Anyway, for both cases I have the message "NoMethodError: undefined > > method `to_b’ for string." What is the scope point in here, > > A string literal, like "string', or "foo" will ALWAYS be an instance > of ::String, and never an instance of Everything::String > > -- > Rick DeNatale > > Blog:http://talklikeaduck.denhaven2.com/ > Github:http://github.com/rubyredrick > Twitter: @RickDeNatale > WWR:http://www.workingwithrails.com/person/9021-rick-denatale > LinkedIn:http://www.linkedin.com/in/rickdenatale Thanks, that solved my scope doubt.