From: Daniel Schierbeck Date: 2006-05-18T03:06:03+09:00 Subject: Re: Dynamically modifying modules to avoid namespace collisi Wes Gamble wrote: > How does this > > str.to_s.split("::").inject(Object) { |ns,name| ns.const_get(name) } > > work? It takes a string on the form "A::B::C" and splits it into an array; ["A", "B", "C"]. When calling #inject on that array, you iterate over each element, yielding them to the block (the second parameter). The first parameter is the result of the last call to the block, or, if it's the first element, the default value, here Object. %w(A B C).inject(Object) {|parent, child| parent.const_get(child) } is the same as Object.const_get(:A).const_get(:B).const_get(:C) Hope that made it clearer Daniel