--nextPart3036087.AgrSCeo0YQ
Content-Type: text/plain;
  charsettf-8"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Da Nedeľa 9. Apríl 2006 20:26 Gyoung-Yoon Noh napísal:
> On 4/10/06, Brian Parkinson <parkI / whatevernot.com> wrote:
> > Hello - I'm bashing my head against the wall - I'm sure this is a simple
> > question, but damned if I can figure it out.
> >
> > If I have a String which corresponds to a class name, how do I create an
> > instance of this class?
> >
> > Example:
> >
> > class MyExampleClass
> >     ...
> > end
> >
> > s = 'MyExampleClass'
> >
> > # We want to instantiate a new instance of the class
> > myExampleClassInstance = ???
> >
> > I want the behaviour of 'MyExampleClass.new' but only using the String
> > value of s.
> >
> > I'm sure it's a one-liner.
> >
> > Any help appreciated.
> >
> > Thanks.
> >
> > parki...
> >
> >
> > --
> > Posted via http://www.ruby-forum.com/.
>
> $ irb
> irb(main):001:0> class K
> irb(main):002:1> end
> => nil
> irb(main):003:0> k1 = K.new
> => #<K:0xb7fc1788>
> irb(main):004:0> k2 = eval('K').new
> => #<K:0xb7fb8094>
> irb(main):005:0> k3 = Object.const_get('K').new
> => #<K:0xb7fb1474>
>
> --
> http://nohmad.sub-port.net

I would, naively hoping to see YARV released Sometime Soon (tm), rather use 
<anything but eval>, since it probably is / will be easier for YARV to work 
with <anything but eval>, as far as optimizations are concerned. It also 
makes the intent of the code clearer.

David Vallner

--nextPart3036087.AgrSCeo0YQ
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQBEOVr3+aUhotvmpDgRAgmfAJ42dBZSePKlQeLdzNXasslx//yJRgCdEhRO
f4WNJWFvsKYadD+IqQB7qQkDi
-----END PGP SIGNATURE-----

--nextPart3036087.AgrSCeo0YQ--