From: David Masover Date: 2009-03-29T13:49:02+09:00 Subject: Re: Dynamic object creation in ruby Clash Fasn wrote: > This works: > > john = eval("Master::Person").new("John") > > This fails: > > frank = Object.const_get("Master::Person").new("Frank") > > Does anyone know why the second way fails? > Because there is no constant named Master::Person. There's a constant named Person inside the constant named Master. This is going to make a lot more sense by example: Object.const_get('Master').const_get('Person').new('Frank') For what it's worth, unless there's a reason to use strings, you may as well use symbols there: Object.const_get(:Master).const_get(:Person).new('Frank')