From: "David A. Black" Date: 2009-06-21T01:36:46+09:00 Subject: Re: 'move into' a module's namespace in irb Hi -- On Sun, 21 Jun 2009, Max Williams wrote: > David A. Black wrote: >> Hi -- >> >> On Sun, 21 Jun 2009, Max Williams wrote: >> >>>>> String.new.class >>> a weird way. >> When you do irb M, you're putting M before all else in the constant >> resolution path. So String.new is really M::String.new. "hello" is >> still a ::String (top-level, core String class), because the existence >> of M::String does not affect the behavior of the literal quotation >> marks (which create a ::String). >> >> >> David > > ah, ok. I thought that > > "hello" > > was the same thing as > > String.new("hello") > > , though? Or, does it bypass the usual lookup table for methods? It bypasses. The literal constructors aren't hooked in to the method-based constructors: irb(main):001:0> def Array.new; "blah"; end => nil irb(main):002:0> Array.new => "blah" irb(main):003:0> [] => [] etc. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) "Ruby 1.9: What You Need To Know" Envycasts with David A. Black http://www.envycasts.com