Dynamic object creation

Thanks go to both you and David (who presented an identical solution shortl
after this). That is so effing cool! Refresh my memory again - why are
they making Perl 6? :stuck_out_tongue:

Regards,

Dan

路路路

-----Original Message-----
From: ts [mailto:decoux@moulon.inra.fr]
Sent: Friday, July 26, 2002 9:20 AM
To: ruby-talk@ruby-lang.org
Cc: ruby-talk@ruby-lang.org
Subject: Re: dynamic object creation

m = "TestClass"
require "#{m}"
t = eval 鈥#{m}.new鈥

eval is evil

pigeon% cat TestClass.rb
class TestClass
end
pigeon%

pigeon% cat b.rb
#!/usr/bin/ruby
m = "TestClass"
require m
p Object.const_get(m).new
pigeon%

pigeon% b.rb
#TestClass:0x401af914
pigeon%

Guy Decoux

Thanks go to both you and David (who presented an identical solution shortl
after this). That is so effing cool! Refresh my memory again - why are
they making Perl 6? :stuck_out_tongue:

Because 鈥淭here鈥檚 More Than One Way To Do It鈥. :slight_smile:

Regards,

Dan

    Hugh
路路路

On Fri, 26 Jul 2002, Berger, Daniel wrote:

Hi 鈥

路路路

On Sat, 27 Jul 2002, Hugh Sasse Staff Elec Eng wrote:

On Fri, 26 Jul 2002, Berger, Daniel wrote:

Thanks go to both you and David (who presented an identical solution shortl
after this). That is so effing cool! Refresh my memory again - why are
they making Perl 6? :stuck_out_tongue:

Because 鈥淭here鈥檚 More Than One Way To Do It鈥. :slight_smile:

Hmmm鈥 interesting cause-effect conundrum: Is there Perl because
there鈥檚 more than one way to do it, or is there 鈥淭here鈥檚 More Than One
Way To Do It鈥 because there鈥檚 Perl?

:slight_smile:

David


David Alan Black
home: dblack@candle.superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav